我正在尝试做一些微不足道的事情,但看不到我错过了什么。我有以下 web.xml...
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
当我使用像“http://localhost:8080/gallery.action http://localhost:8080/gallery.action”,一切工作正常(因为“画廊”在 struts.xml 等中正确配置)。
但是,如果我点击“http://localhost:8080/gallery.do http://localhost:8080/gallery.do相反 - 我收到 404 响应。Tomcat 似乎没有将请求转发到 struts,因为 struts 端没有日志记录。Tomcat 日志仅显示 404。
我尝试将过滤器映射更改为 *.blah,但除了 *.action 之外没有任何效果。我在默认的 web.xml 文件中没有看到任何冲突的信息。
有人知道我错过了什么吗?
显然,Struts2 默认情况下仅识别 .action 扩展名,需要使用 struts.properties 文件根据需要配置其他扩展名:
struts.action.extension=action、do 等
这是非常具有误导性的,因为大多数文档都讨论如何专门使用过滤器映射转发到 struts。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)