SpringBoot注解形式配置过滤器(Filter)

@Component
@Order //过滤器加载的顺序 默认Integer.MAXVALUE
@WebFilter(urlPatterns = "/*",filterName = "wholeFilter") //拦截所有路径
public class WholeFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
       //TODO
        chain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

    }
}

你可能感兴趣的:(spring-boot)