SpringBoot之过滤器
Posted zengnansheng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot之过滤器相关的知识,希望对你有一定的参考价值。
MyFilter1.java
package com.zns.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; @WebFilter(filterName = "myFilter1", urlPatterns = "/*") public class MyFilter1 implements Filter { @Override public void init(FilterConfig config) throws ServletException { System.out.println("过滤器初始化"); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("执行过滤操作"); chain.doFilter(request, response); } @Override public void destroy() { System.out.println("过滤器销毁"); } }
在启动类增加@ServletComponentScan注解
以上是关于SpringBoot之过滤器的主要内容,如果未能解决你的问题,请参考以下文章
springBoot之配置文件的读取以及过滤器和拦截器的使用
[十四]SpringBoot 之 Spring拦截器(HandlerInterceptor)
SpringBoot启动报错“Consider defining a bean of type ‘xxx.mapper.UserMapper‘ in your configuration.“(代码片段
全栈编程系列SpringBoot整合Shiro(含KickoutSessionControlFilter并发在线人数控制以及不生效问题配置启动异常No SecurityManager...)(代码片段