由于this和this问题,我创建了一个Filter
来检查带有请求对象的Cookie
和forward
相应的请求。现在我想将此Filter
映射为我在welcome-file
中声明的web.xml
。{
假设我welcome-file
为index.html
,那么我必须为Filter
和www.example.com/
映射www.example.com/index.html
,而不是www.example.com/foo/*
等其他任何内容或www.example.com/*
是不允许的,我的意思是除welcome-file
请求之外的任何内容。
我正在使用Apache Tomcat 7.0.22容器。
答案 0 :(得分:2)
只需将这些添加到您的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>