SpringBoot入门(13)- SpringBoot 中使用Servlet API

1、静态文件默认路径及配置

autoconfig下的web下的ResourceProperties中

private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
			"classpath:/META-INF/resources/", "classpath:/resources/",
			"classpath:/static/", "classpath:/public/" };

2、在springboot环境中使用servlet API

 a)HttpServlet

 使用注解@WebServlet("path")配置访问路

SpringBoot入门(13)- SpringBoot 中使用Servlet API

在主函数类使用注解@ServletComponentScan扫描Servlet

SpringBoot入门(13)- SpringBoot 中使用Servlet API

serlvet实现方式二:

SpringBoot入门(13)- SpringBoot 中使用Servlet API

b)Filter 接口实现

使用注解@WebFilter(path)配置拦截路径

SpringBoot入门(13)- SpringBoot 中使用Servlet API

在主函数类使用注解@ServletComponentScan扫描Servlet

filter实现方式二:

SpringBoot入门(13)- SpringBoot 中使用Servlet API

c)listener

使用注解@WebListener配置

SpringBoot入门(13)- SpringBoot 中使用Servlet API

在主函数类使用注解@ServletComponentScan扫描Servlet

实现方式二