【发布时间】:2012-11-23 02:36:33
【问题描述】:
我正在使用 Struts2 制作这个 hello world 应用程序,我遇到了一个
HTTP Status 404 - /HelloStruts2/
这是我的web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>HelloStruts2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
这是我的struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!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.devMode" value="true" />
<package name="basicstruts2" extends="struts-default">
<action name="index">
<result>WEB-INF/index.jsp</result>
</action>
<action name="hello"
class="actions.HelloWorldAction" method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
这是我的应用程序中的 jar 列表
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.15.0-GA.jar
jstl-1.2.jar
ognl-3.0.5.jar
struts2-core-2.3.7.jar
xwork-core-2.3.7.jar
【问题讨论】:
-
您已经发布了两次 web.xml 内容。请发布 struts.xml 文件
-
欢迎文件保存在哪里?
-
给出错误日志。我过去有同样的问题,我通过更改 jar 文件解决了。请检查错误日志。我确定 jar 文件有问题。
-
Tomcat 的 catalina.out 中说了什么?最重要的是,在你启动容器(或安装 webapp)之后它会说什么,在你发出请求之后它会说什么?另外,您可能应该记录在您的问题中不起作用的整个请求路径:URL --> struts mapping --> Action class --> 结果模板等
标签: java tomcat struts2 http-status-code-404