struts2.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>
   <include file="struts-default.xml"/>   
   <package name="sunyang" extends="struts-default" namespace="/user">
       <action name="login1">    
       <result name="success">/success.jsp</result>
       <result name="error">/error.jsp</result>
       </action>
    </package>
<constant name="struts.locale" value="en_GB"/>     </struts>
 
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/j2ee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
   <display-name>Struts 2.0 Hello World</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>登录页面主要代码<body>
         <center>
<form action="login1" method=post> 
用户名:<input type=text name=username><br>
密码:<input type=password name=password><br>
<input type=submit value="提交">
</form>
         </center>
  </body>
一点提交就报404错误:HTTP Status 404 - /struts1/WebRoot/login1--------------------------------------------------------------------------------type Status reportmessage /struts1/WebRoot/login1description The requested resource (/struts1/WebRoot/login1) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.10这是什么原因啊,希望各位高手给指点指点!!!!!!!!!!

解决方案 »

  1.   

    <form action="/user/login1.action" method=post> //加上namespace="/user"不使用《S:FORM》需要写上。ACTION
      

  2.   

    <form action="login1" method="post">中,你的login1是往ActionServlet提交,你有Struts-config.xml配置文件吗,错误提示是你的配置文件有问题
      

  3.   


    另外还有你的struts.xml 配置的action 也不对啊<action name="login1" class="****" >    
          <result name="success">/success.jsp </result> 
          <result name="error">/error.jsp </result> 
    </action> 
      

  4.   

    1.<action name="login1">  没有给出实现类 class
    2.包声明了 命名空间namespace 在请求的时候 要加上 /user/login1.action
      

  5.   

    还有个class 属性, 需要配置你的action类
      

  6.   


    另外你的 struts.xml 配置的action 也不对, 还有class 属性你没有写 <action name="login1" class="*********">    
          <result name="success">/success.jsp </result> 
          <result name="error">/error.jsp </result> 
     </action> 
      

  7.   

    明明写了.namespade了.为什么在页面中的action="login1 ?这也太明显了,你先去看看书吧.