gpt4 book ai didi

java - Struts2 没有加载我的 webapp...404 错误?

转载 作者:行者123 更新时间:2023-11-28 22:41:52 25 4
gpt4 key购买 nike

我是 Struts2 的新手,无法在 eclipse/浏览器中的 tomcat 上运行任何涉及它的东西。当我只是在 web.xml 文件中映射 servlets/jsp 时,Tomcat 工作正常,但是当我试图切换到 struts2 时,我无法让它工作。当我尝试在服务器上运行时,它甚至没有转到我的索引 jsp...只是加载了 404 错误。当我无法让我的类(class)应用程序运行并且我也无法运行教程时,我遵循了在线教程。这是我添加到 tomcat lib/build 路径 jars 中的 jar 文件 -

asm-5.0.2.jar             
asm-commons-5.0.2.jar
asm-tree-5.0.2.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
commons-logging-1.1.3.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts-core-1.3.10.jar
struts2-dojo-plugin-2.3.20.jar
xwork-core-2.3.20.jar

过滤器添加到 web.xml -

<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>

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.struts2.files.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>

关于我在尝试运行该应用程序时收到 404 的原因有什么想法吗?

最佳答案

我想,您向类路径 添加了错误的struts-core-1.3.10.jar。这可能属于 Struts 1.x。您需要包含来自 Struts 2 框架的最新 struts2-core-2.x.x.jar

典型的 Struts 2 应用程序在 WEB-INF/lib 目录下有以下 jar。

commons-fileupload-1.2.1
commons-io-1.3.2
commons-logging-1.1
freemarker-2.3.13
junit-3.8.1
ognl-2.6.11
xwork-2.1.2
struts2-core-2.1.6
struts2-convention-plugin-2.1.6 (if using annotations)

尝试从 struts.apache.org 下载最新的 jar .

关于java - Struts2 没有加载我的 webapp...404 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29381030/

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