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("初始化过滤器中......"); } }

 

posted @ 2018-08-09 09:28  何其小静  阅读(333)  评论(0编辑  收藏  举报