我想删除Struts2应用程序中的action后缀扩展。
已添加<constant name="struts.action.extension" value=""/>
到struts.xml
但 Apache 服务器抛出 404 错误。
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [login.jsp] associated with context path [/Ideck_V3].
我正在使用welcome-file-list
在web.xml
对于第一页。
这是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>com.hbs.ideck.common.Struts2Dispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
这是 struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.action.extension" value=""/>
<include file="user.xml"/>
<include file="vendor.xml"/>
<include file="settings.xml"/>
</struts>
我该如何解决这个问题?
最佳答案
默认扩展映射是“,,action”
。这意味着您可以使用映射到带有 .action
后缀或不带后缀的操作名称,因此如果您想删除操作后缀扩展,您需要在 struts.xml
中指定它> 作为
<constant name="struts.action.extension" value=","/>
请注意,没有操作后缀的操作映射仍然保留。它允许解析 url 中的扩展名,如 .jsp
,并且不会与操作名称混淆。
关于java - Struts2操作扩展设置为空时出现404错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31940293/