这是我的web.xml文件代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>myTest</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>  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</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>
    <include file="struts-default.xml"/>
    <package name="test" extends="struts-default">
        <action name="TestAction" class="test.MyTest">
            <result>/print.jsp</result>
        </action>
    </package>
</struts>***************************************************************************************
这是我的JAVA文件代码:package test;import com.opensymphony.xwork2.ActionSupport;public class MyTest extends ActionSupport {

private String name;
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String execute() {
        name = "Hello, " + name + "!"; 
        return SUCCESS;
    }
    }********************************************************************************这是我的主页面index.jsp代码:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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>Insert title here</title>
</head>
<body>
<s:form action="TestAction" >     //************就是这行*************** 
     Name: <s:textfield name="name" />
     <s:submit label="submit"> </s:submit>
</s:form>
</body>
</html>***************************************************************************************问题:
我的主页面index.jsp中就是打注释的那行有问题(有个红差差),说什么“The value [TestAction] for attribute [action] in tag [form] is not valid.” 
在网上查了一下,有人说有个红差不要紧也能跑,我就去试了一下, 
结果: 
HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.请知道的达人能不能指点一下,小弟就这问题已经搞了一整天了

解决方案 »

  1.   

    <include file="struts-default.xml"/>配置文件里引用这个做什么用?我玩struts2到现在从来没引过,你去掉试试。
      

  2.   

    struts2默认会加载struts-default.xml配置文件,然后加载plugin的配置文件,然后才是struts.xml文件。
    不用include
      

  3.   

    哎,我刚试过,去掉了也没有用,还是这样的报错:
    HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.
      

  4.   

    找不到myTest下的TestAction
    你访问方式错了吧
    直接是http://localhost:端口/项目名称
    首先出来的应该是index.jsp
    提交表单后转到print.jsp
      

  5.   

    commons-logging-1.0.4.jar
    freeer-2.3.8.jar
    ognl-2.6.11.jar
    struts2-core-2.0.14.jar
    xwork-2.0.7.jar基础的struts2练习这几个jar就够了,多了可能有冲突。
      

  6.   

    <package name="test" extends="struts-default"> 
    这一行的test改成myTest试试
      

  7.   

    没看出什么问题!
    楼主你这样看看 ,你把package的namespace
    <package name="test" extends="struts-default" namespace="/test"> 
            <action name="TestAction" class="test.MyTest"> 
                <result>/print.jsp </result> 
            </action> 
    </package> <s:form action="TestAction" namespace="/test">
    把method也给加上,别用默认行为,这样看看。。
      

  8.   

    哎,好像都不行,奇怪了,我想不通啊,我在MyTest.java中打了个断点为了看action能不能到java文件,但是断点根本没有动,也就是说,action根本没有指向java文件,但我是从网上找到的例子,而且网上很多struts.xml配置文件都是这样的,我到底是哪里配置错了呢,真的是想不通啊。
      

  9.   

    请问一下,会不会是我的struts.xml配置文件放错路径了?我放在和web.xml一样的路径下了,但我记得我以前在用struts1的时候也是放在一样的路径下的。
      

  10.   

    楼上正解
    现在才注意到这点上来
    struts.xml文件是要放在src下