过滤器生命周期方法
import javax.servlet.*; import javax.servlet.annotation.WebFilter; import java.io.IOException; //生命周期 @WebFilter("/index.jsp") public class FilterDemo3 implements Filter { public void destroy() { System.out.println("服务器关闭时销毁"); } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { System.out.println("demo3..."); chain.doFilter(req, resp); } public void init(FilterConfig config) throws ServletException { System.out.println("服务器开启时只启动一次"); } }