有什么理由说我的过滤器映射不起作用

时间:2013-07-24 15:20:23

标签: java java-ee servlet-filters web.xml url-pattern

当我声明像这样的过滤器映射时:

<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

当我浏览http://localhost:8080/myApp/pages/test.action

时,它会起作用

但如果我这样声明:

<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/pages/*</url-pattern>
</filter-mapping>

它不起作用,我确认我的上下文路径是myApp

我的应用程序部署在JBOSS 5.1上

我希望有人能说出我的错误 提前致谢

编辑: 我的所有过滤映射:

<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>requestInfo</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Single Sign Out Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
    <filter-name>HeaderFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Authentication Filter</filter-name>
    <url-pattern>/pages/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Validation Filter</filter-name>
    <url-pattern>/pages/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>   
<filter-mapping>
    <filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
    <filter-name>CAS Assertion Thread Local Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

1 个答案:

答案 0 :(得分:0)

如果您在url-mapping中提供任何内容,它会尝试映射该映射本身,而不是试图找出您输入的URL。

尝试:

http://localhost:8080/myApp/pages/pages/test.action

如果这样可行,则必须在struts配置文件中更改动作映射。