gpt4 book ai didi

java - web.xml 过滤器映射不转发到 struts

转载 作者:行者123 更新时间:2023-11-30 12:00:38 26 4
gpt4 key购买 nike

我正在尝试做一些微不足道的事情,但看不到我错过了什么。我有以下 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”这样的 URL 时,一切正常(因为“画廊”在 struts.xml 等中正确配置)。

但是,如果我改为点击“http://localhost:8080/gallery.do”——我会收到 404 响应。 Tomcat 似乎没有将请求转发给 struts,因为 struts 端没有日志记录。 Tomcat 日志仅显示 404。

我已经尝试将过滤器映射更改为 *.blah,但除了 *.action 之外没有任何效果。我在默认的 web.xml 文件中没有看到任何冲突信息。

有人知道我错过了什么吗?

最佳答案

显然 Struts2 默认只识别 .action 扩展名,需要使用 struts.properties 文件根据需要配置其他扩展名:

struts.action.extension=action,do,etc

这是非常误导的,因为大多数文档都讨论了如何专门使用过滤器映射转发到 struts。

关于java - web.xml 过滤器映射不转发到 struts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1788631/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com