[英]How to map a filter for welcome-file in web.xml for Tomcat?
我已经创建了一个Filter
来检查带有请求对象的Cookie
并forward
相应的请求,这要归功于这个和这个问题。现在我想将此Filter
映射到welcome-file
因为我在web.xml
声明了它。
假设我有welcome-file
作为index.html
然后我必须映射www.example.com/
和www.example.com/index.html
的Filter
,但不能用于其他任何内容,例如www.example.com/foo/*
或www.example.com/*
是不允许的,我的意思是除了welcome-file
请求之外没有任何东西。 我正在使用Apache Tomcat 7.0.22容器。
只需将这些添加到您的web.xml即可
<filter>
<filter-name>myFilter</filter-name>
<filter-class>com.examples.myFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/index.html</url-pattern>
</filter-mapping>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.