一只丑橘
2017-11-12 17:12
@WebFilter(filterName = "AsynFilter", value = {"/index.jsp"},dispatcherTypes={DispatcherType.REQUEST,DispatcherType.ASYNC})
public class AsynFilter implements Filter {
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
throws IOException, ServletException {
System.out.println("start…………AsynFilter");
arg2.doFilter(arg0,arg1); // 放行
System.out.println("end…………AsynFilter");
}
@Override
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
System.out.println("init…………AsynFilter");
}
}
访问index.jsp之后,不会输出index.jsp中的内容,但是会在控制台输出:
end…………AsynFilter
start…………AsynFilter
这是为什么?好像过滤器没有放行一样,不会执行index中的内容
因为访问index.jsp会立即跳至/servlet/AsynServlet路径,执行AsynFilter
Java Web开发技术应用——过滤器
70492 学习 · 258 问题
相似问题