Home > Back-end >  The filter filter
The filter filter

Time:09-27

Public void doFilter (ServletRequest the req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
Chain. DoFilter (the req, resp);
System. The out. Println (" f2 ");
Chain. DoFilter (the req, resp);
}


Filter2 & lt;/filter - name>
Com. Test. Filter2 & lt;/filter - class>


Filter2 & lt;/filter - name>
/s1 & lt;/url - pattern>



@ WebServlet (name="Servlet1," urlPatterns="/s1")
Public class Servlet1 extends the HttpServlet {
Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {
The response. GetWriter (). Println (" suc ");
}



To ask you, the console output 4 f2, two suc pages to print, because of what? According to my understanding, click on the button, a jump/s1, the request filtering/s1 resources, output a f2, a suc, don't know what went wrong?
  • Related