调用过滤器的顺序是什么?

问题描述:

假设我在我的web.xml中有以下内容

Suppose i have following in my web.xml

<filter-mapping>
    <filter-name>F1</filter-name>
    <url-pattern>/XYZ/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>F2</filter-name>
    <url-pattern>/XYZ/abc.do</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>F3</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

如果请求是/ XYZ / abc,将调用过滤器的顺序是什么.do.And为什么?

What will be the order in which the filters will be called if a request comes as /XYZ/abc.do.And why?

按顺序在web.xml中定义它们的映射

In the order their mappings are defined in web.xml

如果使用注释( @WebFilter ),订单似乎未定义 - 您仍然需要声明< filter-mapping> web.xml中的条目。

If using annotations (@WebFilter) the order seems to be undefined - you still have to declare the <filter-mapping> entries in web.xml.