spring-boot 建立Filter
配置
@WebFilter(filterName="testFilter",urlPatterns="/*")
public class TestFilter implements Filter{
@Override
public void init(FilterConfig filterConfig) 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("過濾器銷燬");
}
}