FirstFilter Filter{ destroy() { System..println(); } doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) IOException, ServletException { System..println(); filterChain.doFilter(servletRequest,servletResponse); System..println(); } init(FilterConfig filterConfig) ServletException {System..println(); } }
这是FirstFilter
SecondFilter Filter { destroy() { System..println(); } doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) IOException, ServletException { System..println(); filterChain.doFilter(servletRequest,servletResponse); System..println(); } init(FilterConfig filterConfig) ServletException { System..println(); } }
在设置tomcat 服务器的时候把
Server
Open browser 的 After launch 勾掉,手动开启浏览器网页可以解决
因为你SecondFilter类里面的doFilter方法有一句
filterChain.doFilter(servletRequest,servletResponse);
所以处理了两次
没看粗来 代码也没贴出来 你贴伪代码给谁看捏