过滤器的调用顺序是什么? [英] What will be the order in which filters will be called?
本文介绍了过滤器的调用顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我的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的形式出现,过滤器的调用顺序是什么?为什么?
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
),则命令似乎未定义-您仍然必须在web.xml中声明<filter-mapping>
条目.
If using annotations (@WebFilter
) the order seems to be undefined - you still have to declare the <filter-mapping>
entries in web.xml.
这篇关于过滤器的调用顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文