# springboot-filter-starter **Repository Path**: wslml/springboot-filter-starter ## Basic Information - **Project Name**: springboot-filter-starter - **Description**: 简单的springboot项目,包含了过滤器,监听器,拦截器,场景启动器 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-03 - **Last Updated**: 2021-02-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # springboot-filter-starter #### 介绍 简单的springboot项目,包含了过滤器,监听器,拦截器,场景启动器 ●项目启动后,首先测试过滤器,所有访问路径都需经过我们自定义的filter,如果路径中包含/index、/asd、/online、/login则直接通过,否则则被重定向至/login。 ●然后测试监听器,先访问http://localhost:8080/index,创建session对象(因为 session对象创建需要显示的调用getsession方法),然后访问http://localhost:8080/online,然后换一个浏览器做相同操作,如下: ●最后测试拦截器,代码展示了如何获取@PathVariable注解的请求参数以及普通请求参数,首先访问http://localhost:8080/asd/zhangsan?username=lisi,响应正常,如果访问路径上的名字不是zhangsan,则被拦截,例如http://localhost:8080/asd/wangwu?username=lisi,如下: ●在实际项目中我们还可以在配置的时候设置过滤器、拦截器的执行顺序及其它的参数,同时filter和listener还有对应的注解方式:@WebFilter和@WebListener,在使用注解方式时不要忘了在主程序加上@ServletComponentScan注解,这样才能在程序启动时将对应的bean加载进来。