【发布时间】:2017-09-01 01:18:26
【问题描述】:
我一直在关注this Struts 教程。
这是我的文件结构:
我以为我一步一步地遵循了一切,我之前做过一个类似的教程,并且能够让它在另一个版本中工作,但我现在正在尝试 Struts 2.3.33。我在 Apache Tomcat 8.5 服务器上运行它。我尝试转到http://localhost:8080/HelloWorldStruts2/index.jsp,但它给出了 404 错误消息,我不知道为什么。我还确保 Struts 文件位于我的构建路径和部署程序集以及我的 WEB-INF/lib 文件夹中。
我的控制台没有错误,这是我的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<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"
id="WebApp_ID" version="3.0">
<display-name>Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>/*</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="helloworld" extends="struts-default">
<action name="hello"
class="com.tutorialspoint.struts2.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
【问题讨论】:
-
此版本不适用于 jre 1.8
-
@Roman C 我使用 OP 的环境(Struts 2.3.33 和 Tomcat 8.5)运行了本教程,它使用 JRE 1.8 对我有用。请参阅下面的更新帖子。
-
OP的环境是什么意思?据我阅读该教程,它使用的是 Struts 2.2.3,与 JRE 版本无关。