Python 官方文档:入门教程 => 点击学习
SpringBoot配置suffix指定mvc视图后缀 如下所示: spring: #配置MVC视图后缀 mvc: view: suffix: ".htm
访问welcome.html页面时只需要写“welcome”即可。
@Controller
public class demoController {
@GetMapping("/a")
public String demo(){
return "welcome";
}
运行结果:
package com.ias.oil.client.schedule;
import com.ias.oil.model.OILService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.WEB.servlet.ServletReGIStrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.DispatcherServlet;
@EnableDiscoveryClient
@EnableFeignClients({OILService.PACKAGE_FOR_SERVICE_SCHEDULE})
@SpringBootApplication
public class OILScheduleClientApplication {
public static void main(String[] args) {
SpringApplication.run(OILScheduleClientApplication.class, args);
}
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean bean = new ServletRegistrationBean(dispatcherServlet);
bean.addUrlMappings("*.action");
return bean;
}
}
需要添加上面代码片段的此部分
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean bean = new ServletRegistrationBean(dispatcherServlet);
bean.addUrlMappings("*.action");
return bean;
}
spring:
mvc:
##设置匹配.action后缀的请求的配置
pathmatch:
use-suffix-pattern: false
use-registered-suffix-pattern: true
contentneGotiation:
favor-path-extension: false
~~~~~完活
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Springboot配置suffix指定mvc视图的后缀方法
本文链接: https://lsjlt.com/news/129714.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0