调用过滤器的顺序是什么? [英] What will the the order in which filters will be called?

查看:90
本文介绍了调用过滤器的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在我的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.

这篇关于调用过滤器的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆