您的位置:首页 > 其它

多个Filter 的执行顺序

2012-07-13 17:18 246 查看
如果在WEB.XML中有多个Filter,则执行顺序为
<filter-mapping>的顺序

<filter-mapping>
<filter-name>secondFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>sysoutFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

执行顺序为 secondFilter, sysoutFilter

Configuring a Chain of Filters

WebLogic Server creates a chain of filters by creating a list of all the filter mappings that match an incoming HTTP request. The ordering of the list is determined by the following sequence:

Filters where the
filter-mapping
element contains a
url-pattern
that matches the request are added to the chain in the order they appear in the
web.xml
deployment descriptor.

Filters where the
filter-mapping
element contains a
servlet-name
that matches the request are added to the chain
after the filters that match a URL pattern.

The last item in the chain is always the originally requested resource.

In your filter class, use the
FilterChain.doFilter()
method to invoke the next item in the chain.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: