Java HTTP 404错误-在简单Struts2应用程序中

Java HTTP 404错误-在简单Struts2应用程序中,java,eclipse,tomcat,struts2,http-status-code-404,Java,Eclipse,Tomcat,Struts2,Http Status Code 404,一个简单的hello world应用程序显示http-404错误 我正在使用以下工具: 1) 月食4.4 2) Apcache tomcat 7.0 3) jdk7 应用程序结构 我是否丢失了jar文件??? index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W

一个简单的hello world应用程序显示http-404错误

我正在使用以下工具:

1) 月食4.4

2) Apcache tomcat 7.0

3) jdk7


应用程序结构

我是否丢失了jar文件??? index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Simple form</title>
</head>
<body>
<form action="Myaction" method="get">
<input type="text" name="t1"><br>
<input type="submit" value="GO">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome | Home</title>
</head>
<body>
<label>Welcome -> <s:property value="t1"/> </label>
</body>
</html>

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="default" extends="struts-default">

    <action name="Myaction" class="com.Action.Myaction" method="execute">
        <result name="success" type="redirect">/Welcome.jsp</result>
    </action>
</package>
</struts>

/Welcome.jsp

Welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Simple form</title>
</head>
<body>
<form action="Myaction" method="get">
<input type="text" name="t1"><br>
<input type="submit" value="GO">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome | Home</title>
</head>
<body>
<label>Welcome -> <s:property value="t1"/> </label>
</body>
</html>

欢迎回家
欢迎->

显示此警告的标记

--在生成路径中找不到

另外,服务器显示错误:资源不可用 如何解决这个错误


谢谢

尝试将struts-.dtd从strut2.core-version.jar提取到WEB-INF/classes并重新运行该项目。

解决方案是:

在web项目中

1) 转到生成路径配置生成路径

2) 如果您使用的是外部JRE,那么它将给出HTTP404错误,所以我使用了JDK i、 e.添加库-库-已安装的JRE

3) 给出JDK的路径。(我们必须使用内部JRE)

4) 完成

5) 刷新项目


它会工作的。

仍然显示错误:严重:异常启动筛选器struts2 java.lang.ClassNotFoundException:>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndexecuteFilteren即使我使用的是struts 2.3.20版本,它大于2.0,您确定这些JAR也会进入tomcat中的lib文件夹吗?您也可以在您上传的JAR未被导出的屏幕截图。所以你需要解决这个问题&你会没事的。现在,你可以手动复制jar并将它们粘贴到tomcat/webapps/your_app/WEB_INF/lib文件夹中。通过这种方式,我们可以确定这是否是确切的问题。要解决此错误,我们需要知道请求了什么资源。类路径中存在大量垃圾<例如,代码>Struts2-core-2.0.1.2.jar,以及所有其他内容。请仔细检查类路径,修复它,清理所有内容,然后重试。