我正在制作一个小型的webapp (这可能被认为是一个uni任务)。我的工具是java7,tomcat7.0.40。
我有一个过滤器,叫做FlowFilter。下面是FlowFilter在web.xml中的定义和映射:
<filter>
<filter-name>FlowFilter</filter-name>
<filter-class>path.to.filter.FlowFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>FlowFilter</filter-name>
<url-pattern></url-pattern>
<url-pattern>*.flow</url-pattern>
<url-pattern>*.request</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>我的webapp根目录是:http://[host]/mywebapp。
我还通过web.xml配置了一个欢迎文件:
<welcome-file-list>
<welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>从映射中可以看出,我需要在以下3种情况下精确执行FlowFilter:
问题是,在第三种情况下从未调用过FlowFilter。
正如我在servlet-3规范、12.2和6.2.4中所读过的,url模式规则适用于过滤器。
但是当我调试Tomcat的ApplicationFilterFactory.matchFiltersURL时,过滤器的url模式从来没有与“映射”相匹配。
问题是:只是Tomcat还没有实现这样的特性,还是我误读了规范或者我用错误的方式映射过滤器,以及为什么。
谢谢。
https://stackoverflow.com/questions/17630307
复制相似问题