标签:filter过滤器 system boot ide val ring void request res
1. 在springboot中添加filter过滤器
可以注解的形式添加 ,但是注意对于 @WebFilter,属于servlet的产物,需要在springboot中引入
@Component 成为组件
@ServletComponentScan 才可扫描到
@WebFilter可指定server,value 和 urlPatterns, 其中value优先级最低
注意filter要用java.servlet.Filter
@Component
@WebFilter(urlPatterns = { "/pc/*"}) public class ApplicationPCFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println(""); } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { filterChain.doFilter(servletRequest,servletResponse); } @Override public void destroy() { }
标签:filter过滤器 system boot ide val ring void request res
原文地址:https://www.cnblogs.com/DennyZhao/p/12512485.html