struts2新手入门被最简单的高懵了 各大侠帮忙!直接代码!//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.FilterDispatcher  
        </filter-class>  
    </filter>                                                                            
             <filter-mapping>  
                <filter-name>struts2</filter-name>  
                <!-- 任何请求均有过滤器 -->  
                <url-pattern>/*</url-pattern>  
             </filter-mapping>  
</web-app>
//struts.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<struts>
<package name="Helloword" namespace="/" extends="struts-default">
<action name="Helloword" class="mypackage.Helloword">
<result >/WebRoot/helloJsp.jsp</result>
</action>
</package>
</struts>
</xml-body>//MyloginJsp.jsp  主要的页面
<%@ page language="java" import="java.util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page contentType="text/html;charset=utf-8" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyloginJsp.jsp' starting page</title>
  
  </head>
  
  <body>
    This is my JSP page. <br>
    <form action="Helloword.action" method="post" >
    <table align="center">
    <tr><td><input type="text" name="name" /></td></tr>
  
    <tr><td><input type="submit" value="submit"/> </td></tr>
    </table>
    </form>
  </body>
</html>各个文件的层次结构

解决方案 »

  1.   

    补下文件结构
    Thestruts2
       src
          mypackage
              Helloword.java
          struts.xml
       WebRoot
          WEB-INF
              web.xml
          MyloginJsp.jsp
          helloJsp.jsp
      

  2.   

    补下文件结构
    Thestruts2
      src
      --mypackage
      ----Helloword.java
      --struts.xml
      WebRoot
      --WEB-INF
      ----web.xml
      --MyloginJsp.jsp
      --helloJsp.jsp
      

  3.   

    你的action配置里面:
    <?xml version="1.0" encoding="UTF-8"?>
    <xml-body>
    <struts>
    <package name="Helloword" namespace="/" extends="struts-default">
    <action name="Helloword" class="mypackage.Helloword">
    <result >/WebRoot/helloJsp.jsp</result></action>
    </package>
    </struts>
    </xml-body>
    好像不用加前面的/WebRoot
    应该是:<result>/helloJsp.jsp</result>
      

  4.   

    <result >/helloJsp.jsp</result>
      

  5.   

    HTTP Status 404 - /Thestructs21/Helloword.actiontype Status reportmessage /Thestructs21/Helloword.actiondescription The requested resource (/Thestructs21/Helloword.action) is not available.Apache Tomcat/7.0.19
      

  6.   

    HTTP Status 404 - /Thestructs21/Helloword.action Thestructs21下没找到名字为Helloword.action 的action,我看你工程名字是Thestruts2,工程名字不对吧.
     
      

  7.   

     /Thestructs21/Helloword.action改成 /Thestructs2/Helloword.action 试试
      

  8.   

    Thestruts2 这个是你工程名。。
    HTTP Status 404 - /Thestructs21/Helloword.action    这里面变成Thestructs21了。。
      

  9.   

    不好意思上面的纯属打错了工程名字也是Thestructs21的;
    工程名这个不是问题的
    我用http://localhost:8080/Thestructs21/WebRoot/MyloginJsp.jsp是能正常访问的