search

Home  >  Q&A  >  body text

java - Filtering order when Servlet filter uses annotation to declare filtering address?

First of all, I know that configuring filters under web. After that, the second filter filters, and finally to the Servlet:
Servlet configuration:

@WebServlet(name = "LoginSvlt", urlPatterns = "/f1/f2/xxx.do") First layer Filter configuration:

@WebFilter(description = "first filter", urlPatterns = { "/f1/*" })Second Filter configuration :

@WebFilter(description = "Second filter", urlPatterns = { "/f1/f2/*" })Request:

<form action="/../f1/f2/xxx.do" method="post">...</form>But in fact, every time the Servlet is requested, it will enter the second filter first. filter, then enter the first filter, then enter the second filter, and finally reach the Servlet. What is the difference between using annotation configuration and configuring the filter under web.xml?

高洛峰高洛峰2775 days ago725

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-17 10:01:11

    Using the @WebFilter annotation cannot guarantee the filtering order, or it is not defined in the Servlet 3.0 specification.

    For details, please refer to: http://stackoverflow.com/ques...

    reply
    0
  • Cancelreply