拦截路径配置:
package com.code_g.filter; import javax.servlet.*; import javax.servlet.annotation.WebFilter; import java.io.IOException; //拦截路径配置 //@WebFilter("/index.jsp") //具体资源路径 //@WebFilter("/servlet/*") //拦截目录 //@WebFilter("*.jsp") //扩展名拦截 @WebFilter("/*") //所有资源 public class FilterDemo4 implements Filter { public void destroy() { } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { System.out.println("过滤..."); chain.doFilter(req, resp); } public void init(FilterConfig config) throws ServletException { } }