I have created a Filter
to check the Cookie
s with request object and forward
the request accordingly thanks to this and this question..Now I want to map this Filter
for just the welcome-file
as I have declared it in web.xml
.
Say I have welcome-file
as index.html
then I have to map the Filter
for both www.example.com/
and www.example.com/index.html
but not for anything else such as www.example.com/foo/*
or www.example.com/*
is not allowed, I mean NOT anything except welcome-file
request.
I am using Apache Tomcat 7.0.22 container.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Just add these to your 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>