java - Filtering order when Servlet filter uses annotation to declare filtering address?
高洛峰
高洛峰 2017-05-17 09:59:11
0
1
720

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?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
为情所困

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...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template