繁体   English   中英

如何在web.xml中为Tomcat映射welcome-file的过滤器?

[英]How to map a filter for welcome-file in web.xml for Tomcat?

我已经创建了一个Filter来检查带有请求对象的Cookieforward相应的请求,这要归功于这个这个问题。现在我想将此Filter映射到welcome-file因为我在web.xml声明了它。
假设我有welcome-file作为index.html然后我必须映射www.example.com/www.example.com/index.htmlFilter ,但不能用于其他任何内容,例如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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM