开发者

Can we confgure filters only for a subset of servlets

I have various different categories of servlets. Can I configure the filters in my web.xml such that each filter only applies for one of the categories of 开发者_如何学Pythonservlet.


You can map them on <servlet-name> instead of <url-pattern>.

<filter-mapping>
    <filter-name>yourFilterName</filter-name>
    <servlet-name>yourServlet1Name</servlet-name>
    <servlet-name>yourServlet2Name</servlet-name>
    <servlet-name>yourServlet3Name</servlet-name>
</filter-mapping>

The <servlet-name> must exactly match the same value as in <servlet> definition. This way the filter will be invoked whenever either of those servlets are to be invoked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜