拦截方式配置:资源被访问的方式
import javax.servlet.*; import javax.servlet.annotation.WebFilter; import java.io.IOException; //拦截方式配置 @WebFilter(value = "/index.jsp", dispatcherTypes = {DispatcherType.REQUEST,DispatcherType.FORWARD}) public class FilterDemo5 implements Filter { public void destroy() { } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { System.out.println("拦截请求或者转发到index.jsp的资源"); chain.doFilter(req, resp); } public void init(FilterConfig config) throws ServletException { } }