struts2 报错.action is not available

cdsn09 2009-07-30 04:31:07
本来是好的,后来恢复系统后,原来的工程有的地方就出错了(虽然是在D盘,但还是丢失了一些工程需要的jar包,这些jar包引自D盘,这也是没想明白的地方,为什么恢复系统D盘的东西会丢)。
现在的问题是没有出错的工程也运行不了了
是struts2最简单的例子,jar包都检查了没问题。tomcat刚刚重装,在系统变量中classpath中添加了tomcat的lib。
报错:
type Status report

message /test/WebRoot/hello.action

description The requested resource (/test/WebRoot/hello.action) is not available.

工程用<Context>和直接放在tomcat的webapp下都不行。
第一个页面index.jsp可以正常显示,点击“进入”就提示上述错误。
工程目录确定没错!
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
xwork-2.0.3.jar
struts2-core-2.0.8.jar
这些包是恢复系统之前用的都可以成功运行。只要后五个包,但听有人说前两个也要,但是不管前俩有没有都不行。
恢复系统应该没对工程有多少影响,应该考虑tomcat(刚刚重装,显示基本页面没用问题)?或者系统的别的地方有影响工程运行的??请高手帮忙!

代码:
index.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>index</title>
</head>

<body>
<a href="hello.action">进入</a>
</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>
<package name="wutao" extends="struts-default">
<action name="hello" class="test.TestAction">
<result name="success">
/hello.jsp
</result>
</action>
</package>
</struts>
-------------------------------------------------------------------------------------------------------

action:
package test;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class TestAction extends ActionSupport {
private String message = "hello word";

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

@Override
public String execute() throws Exception {
return SUCCESS;
}
}

------------------------------------------------------------------------------------------------------

hello.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>My JSP 'fuck.jsp' starting page</title>
</head>

<body>
<s:property value="message"/>

</body>
</html>
======================================================================================================





...全文
241 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
public_private 2010-05-06
  • 打赏
  • 举报
回复
看你都出了一年了 解决了的话 也不给个解决的方案给我们看哈
public_private 2010-05-06
  • 打赏
  • 举报
回复
明天再帮你解决!现在要回家了
cdsn09 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zrcai 的回复:]
(/test/WebRoot/hello.action)
怎么会跳到WebRoot下?
[/Quote]本来所有的东西都是在test/webroot下的,默认myeclipse是会给产生一个webroot的
cdsn09 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wqnljy 的回复:]
struts.xml中继承 struts-default.xml 中的struts-default
<struts name="struts2" extends="struts-default">

[/Quote]哥,这不是已经继承了吗??
cdsn09 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 rk1982 的回复:]
你struts.xml里的package不是wutao么,路径应该是/wutao/hello.action啊。
[/Quote]这个package名和路径没关系的吧?我开始时可以运行的恢复系统后出了问题,应该不是这的问题
rk1982 2009-07-30
  • 打赏
  • 举报
回复
你struts.xml里的package不是wutao么,路径应该是/wutao/hello.action啊。
zrcai 2009-07-30
  • 打赏
  • 举报
回复
(/test/WebRoot/hello.action)
怎么会跳到WebRoot下?
ImAHunter 2009-07-30
  • 打赏
  • 举报
回复
<package name="wutao" extends="struts-default"> 还有其他struts.xml文件?
wqnljy 2009-07-30
  • 打赏
  • 举报
回复
struts.xml中继承 struts-default.xml 中的struts-default
<struts name="struts2" extends="struts-default">
cdsn09 2009-07-30
  • 打赏
  • 举报
回复
根据你所请的 hello.action struts 遇到以.action 结尾的将自己去掉后缀,最后为 hello
struts 查找struts.xml 文件里是否存在名为 hello的action .
这应该是struts2的大体工作原理,请问这里去掉后缀具体是“谁”干的?
这个问题好像就是没有人去后缀,然后到struts.xml中查找,,,而是直接把hello.action当作请求页,所以会报hello.action is not available.
请高手帮忙分析一下。
cdsn09 2009-07-30
  • 打赏
  • 举报
回复
web.xml没有问题。确定。

67,515

社区成员

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

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