本来是好的,后来恢复系统后,原来的工程有的地方就出错了(虽然是在D盘,但还是丢失了一些工程需要的jar包,这些jar包引自D盘,这也是没想明白的地方,为什么恢复系统D盘的东西会丢)。
现在的问题是没有出错的工程也运行不了了
是struts2最简单的例子,jar包都检查了没问题。tomcat刚刚重装,在系统变量中classpath中添加了tomcat的lib。
报错:
type Status reportmessage /test/WebRoot/hello.actiondescription 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
freeer-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>
======================================================================================================

解决方案 »

  1.   

    根据你所请的 hello.action struts 遇到以.action 结尾的将自己去掉后缀,最后为 hello 
    struts 查找struts.xml 文件里是否存在名为 hello的action .
    这应该是struts2的大体工作原理,请问这里去掉后缀具体是“谁”干的?
    这个问题好像就是没有人去后缀,然后到struts.xml中查找,,,而是直接把hello.action当作请求页,所以会报hello.action is not available.
    请高手帮忙分析一下。
      

  2.   

    <package name="wutao" extends="struts-default"> 还有其他struts.xml文件?
      

  3.   

    (/test/WebRoot/hello.action)
    怎么会跳到WebRoot下?
      

  4.   

    你struts.xml里的package不是wutao么,路径应该是/wutao/hello.action啊。
      

  5.   

    struts.xml中继承 struts-default.xml 中的struts-default
    <struts name="struts2" extends="struts-default"> 
      

  6.   

    这个package名和路径没关系的吧?我开始时可以运行的恢复系统后出了问题,应该不是这的问题
      

  7.   

    本来所有的东西都是在test/webroot下的,默认myeclipse是会给产生一个webroot的