springboot过滤器的实现
springboot过滤器的实现
如下所示:
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
@WebFilter(filterName="SpringbootFilter",urlPatterns="/security/**") public class SpringbootFilter implements Filter { public ServletFilter() { } public void destroy() { System.out.println("过滤器已被销毁......"); } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("过滤器正在执行......"); chain.doFilter(request, response); } public void init(FilterConfig fConfig) throws ServletException { System.out.println("初始化过滤器中......"); } }
程序员的眼里,不止有代码和bug,还有诗与远方和妹子!!!