struts2的问题,jar包都导了,为什么运行不了?

wukaiying01 2012-03-22 02:48:40
问题错误:
HTTP Status 404 - //teststruts2-2/helloworld

type Status report

message //teststruts2-2/helloworld

description The requested resource (//teststruts2-2/helloworld) is not available.

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">
<display-name></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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.action</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>
<package name="login" namespace="/" extends="struts-default">
<action name="helloworld" class="cn.itcast.action.HelloWorldAction" method="execute">
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
</package>

</struts>

java文件
package cn.itcast.action;

public class HelloWorldAction {
private String message;
public String getMessage() {//Message决定参数
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String execute(){
message="我的第一个struts2";
return "success";
}

}


jsp文件
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'hello.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
${message}
</body>
</html>
...全文
126 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxw3152 2012-03-23
  • 打赏
  • 举报
回复
把jar包中名字一样的但是版本不一样的 删掉一个。。应该是版本冲突。。
baolong101010 2012-03-22
  • 打赏
  • 举报
回复
你这里缺一段配置:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.jsp</url-pattern>
</filter-mapping>

加上去试试看,对的话,记得给我分哦。
wukaiying01 2012-03-22
  • 打赏
  • 举报
回复
http://localhost:8080//teststruts2-2/helloworld
liguangwen86 2012-03-22
  • 打赏
  • 举报
回复
把你访问的路径贴出来,还有把你想访问的文件路径结构贴出来,这个就是没找到访问的页面
wukaiying01 2012-03-22
  • 打赏
  • 举报
回复
会不会是版本不兼容问题?
wukaiying01 2012-03-22
  • 打赏
  • 举报
回复
HTTP Status 404 - /teststruts2-2//WEB-INF/page/hello.jsp

type Status report

message /teststruts2-2//WEB-INF/page/hello.jsp

description The requested resource (/teststruts2-2//WEB-INF/page/hello.jsp) is not available.

不行。
wukaiying01 2012-03-22
  • 打赏
  • 举报
回复
HTTP Status 404 - /teststruts2-2//WEB-INF/page/hello.jsp

type Status report

message /teststruts2-2//WEB-INF/page/hello.jsp

description The requested resource (/teststruts2-2//WEB-INF/page/hello.jsp) is not available.

不行。
菖蒲老先生 2012-03-22
  • 打赏
  • 举报
回复
肯定就是路径不对啊。

试试直接访问jsp文件呢。
wukaiying01 2012-03-22
  • 打赏
  • 举报
回复
路径没错,肯定是对的。
wuyi12052008 2012-03-22
  • 打赏
  • 举报
回复

HTTP Status 404 - //teststruts2-2/helloworld

type Status report

message //teststruts2-2/helloworld


资源文件访问不了,你的访问路径是不是正确的啊?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧