HelloReader.jsp的代码:
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
    <head>
        <title>TEST</title>
    </head>
    <body>
        <h2><s:property value="message" /></h2>
    </body>
</html>
web.xml的代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Struts Blank</display-name>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>struts.xml的代码:
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="tutorial" extends="struts-default">
        <action name="HelloReader" class="tutorial.HelloReader">
            <result>/HelloReader.jsp</result>
        </action>
    </package>
</struts>
HelloReader.java的代码:
package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloReader extends ActionSupport { public static final String MESSAGE = "Hello Reader ! I'm from Struts 2";    public String execute() throws Exception {
        setMessage(MESSAGE);
        return SUCCESS;
    }
    private String message;
    public void setMessage(String message){
        this.message = message;
    }    public String getMessage() {
        return message;
    }
}
没有用到其他文件了,在IE中输入http://localhost:8081/Struts2/HelloReader.action时显示内容如下:HTTP Status 404 - --------------------------------------------------------------------------------type Status reportmessage description The requested resource () is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20
这是怎么回事啊,我都调了3个小时了,请大家赐教。

解决方案 »

  1.   

    本来想贴一张图片来说明这4个文件的结构来着,没有成功描述一下吧:Tomcat 6.0\webapps\Struts2下有文件HelloReader.jsp
    Tomcat 6.0\webapps\Struts2\WEB-INF下有文件web.xml
    Tomcat 6.0\webapps\Struts2\WEB-INF\classes下有文件struts.xml
    D:\Tomcat 6.0\webapps\Struts2\WEB-INF\classes\tutorial有文件HelloReader.class不知道还需要不需要其它的配置文件,望赐教。
      

  2.   

    我都查了几遍了,眼睛都花了。呵呵。
    是不是web.xml中的org.apache.struts2.dispatcher.FilterDispatcher 的问题,
    难道不需要其它的配置文件了吗?
      

  3.   

    所需要的jar包拷贝到Tomcat 6.0\webapps\Struts2\WEB-INF\lib目录了没有,配置在web.xml中的struts2的过滤器启动成功了吗?最好用像myeclipse这样的工具来调试一下,先看在tomcat启动时,需要启动的servlet、过滤器、监听器等启动有没有异常,然后再检查配置的路径、大小写等问题,如果你的struts2的过滤器启动失败,你在浏览器中的输入同样不能转到struts2的逻辑上去,而出现你所遇到的问题。
      

  4.   

    org.apache.struts2.dispatcher.FilterDispatcher需要哪个JAR包?
      

  5.   

    你看看tomcat的安装目录下\conf\server.xml的最后 <Context path="struts2" docBase="F:\workspace\ssh\WebRoot" reloadable="true" />。有这个话吗。把你的东西配置上,看看管事吗
      

  6.   

    把Struts下的jar包拷贝到WEB-IEF下的lib目录下
    <%@ taglib prefix="s" uri="/struts-tags" %> 这一句中的URI引用的好像也不对吧
    在web.xml文件中你好像也没有配置Struts所需要的xml文件默认的是struts-config.xml
    建议你去看一下Struts中给你带的那个空项目,里面所有基本的配置。