springtoot过滤器注解方法
启动类加入@ServletComponentScan注解
package com.llf.utils; import javax.servlet.*; import javax.servlet.annotation.WebFilter; import java.io.IOException; @WebFilter(filterName = "mfilter",urlPatterns = "/*") public class MyFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.print("初始化。。。。。。。。。。。。。。。。。。。。。。。。。"); } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.print("自定义过滤器。。。。。。。。。。。。。。。。。。。"); filterChain.doFilter(servletRequest,servletResponse); } @Override public void destroy() { System.out.print("销毁。。。。。。。。。。。。。。。。。。。。。。。。。"); } }