如何在spring-boot中自定义dispatchServlet的访问路径
2017-03-07 08:56
417 查看
在程序的主入口中定义dispatchRegistration
package com.lzl; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.DispatcherServlet; import com.lzl.servlet.MyServlet; @SpringBootApplication public class SpringBootDemoApplication { public static void main(String[] args) { SpringApplication.run(SpringBootDemoApplication.class, args); } @Bean public ServletRegistrationBean dispatcherRegistration(DispatcherServlet dispatcherServlet) { ServletRegistrationBean reg = new ServletRegistrationBean(dispatcherServlet); reg.getUrlMappings().clear(); reg.addUrlMappings("*.html"); reg.addUrlMappings("*.do"); return reg; } }
相关文章推荐
- spring boot扫描自定义的servlet和filter
- Spring Boot下如何自定义Repository中的DAO方法
- SpringBoot如何导入自定义配置的yml文件
- SpringBoot如何导入自定义配置的yml文件
- 关于No mapping found for HTTP request with URI [访问路径] in DispatcherServlet with dispatche
- SpringBoot(3) 自定义servlet
- SpringBoot项目如何访问jsp页面
- 常规容器下SpringBootServletInitializer如何实现web.xml作用解析
- springboot 1.5.2 thymeleaf 添加templates 静态资源访问路径
- SpringBoot如何导入自定义配置的yml文件
- SpringBoot如何导入自定义配置的yml文件
- Spring boot 参数拼在访问路径中,如果参数带 点(符合)后面数据取不到
- 利用Nginx负载均衡的访问SpringBoot服务,还有如何利用Nginx实现404,500等错误页面的拦截
- springboot(2)-springboot中的配置文件设置之(修改访问端口和访问路径)
- springboot如何使用thymeleaf模板访问html页面
- 常规容器下SpringBootServletInitializer如何实现web.xml作用解析
- Spring boot如何写一个自定义的auto-configuration(下)
- IntelliJ IDEA 学习SpringBoot(2) thymeleaf 资源访问和路径写法
- SpringBoot系列<四>视图解析、路径-资源映射、静态资源访问
- springboot扫描自定义的servlet和filter代码详解