使用的是Tomcat 6.0,jdk 1.6, struts-2.2.3.1lib 文件下的内容:
commons-fileupload-1.2.2.jar,commons-io-2.0.1.jar,commons-lang-2.5.jar,commons-logging-1.1.1.jar,freeer-2.3.16.jar,javassist-3.11.0.GA.jar,ognl-3.0.1.jar,struts2-core-2.2.3.1.jar,xwork-core-2.2.3.1.jar这些配置上都没有问题。文件存放的位置也是正确的,但是,运行时出错。HTTP Status 404 - /web/Login--------------------------------------------------------------------------------type Status reportmessage /web/Logindescription The requested resource (/web/Login) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.35正面是我的代码web.xml<?xml version="1.0" encoding="GBK"?>  
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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_3_0.xsd">  
  
    <!-- struts2在web.xml中的配置 -->  
    <filter>  
        <filter-name>struts2</filter-name>  
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
    </filter>  
    <!-- Filter拦截所有用户请求 -->  
    <filter-mapping>  
        <filter-name>struts2</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
  
    <welcome-file-list>  
        <welcome-file>index.jsp</welcome-file>  
    </welcome-file-list>  
  
</web-app>  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="struts2" extends="struts-default">
    
     <action name="hello" class="LoginAction">
     <result name="success">/hello.jsp</result>
                            <result name="error">/error.jsp</result>
     </action>
    
     </package>
    
    </struts>java类public class LoginAction {
private String username ;
private String password ;
public void setUsername(String username){
this.username = username ;
}
public String getUsername(){
return username ;
}
public void setPassword(String password){
this.password = password ;
}
public String getPassword(){
return password ;
}
public String execute() throws Exception {
if("admin".equals(getUsername()) && "123456".equals(getPassword())){
return "success" ;
}else{
return "failure" ;
}
}
}
正面是几个简单的jsp页面login.jsp<%@ page contentType="text/html; charser=gb2312" language="java" %>
<html>
  <body>
<form action="Login" method="post">
name:<input type="text" name="username" /><br>
password:<input type="password" name="password"/><br>
<input type="submit" value="submit"/>
<input type="reset" value="reset">
</form>
  </body>
</html>
error.jsp<%@ page language="java" contentType="text/html; charset=GBK"%>
<html>
<head>
<title>error<title>
<head>
<body>
error!
<body>
<html>hello.jsp<%@ page contentType="text/html; charset=utf-8"%>
<html>
<body>
<h1>hello, this is a struts2 page......</h1>
hello!
</body>
</html>

解决方案 »

  1.   

    <form action="Login" method="post">
    name:<input type="text" name="username" /><br>
    password:<input type="password" name="password"/><br>
    <input type="submit" value="submit"/>
    <input type="reset" value="reset">
    </form>你那里来的Login action 呢?
    你写的是hello action 
    <action name="hello" class="LoginAction">
      <result name="success">/hello.jsp</result>
      <result name="error">/error.jsp</result>
      </action>你随便改一个过来就可以了。
      

  2.   

    <action name="hello" class="LoginAction">
    改成<action name="Login" class="LoginAction">就可以
      

  3.   

    对不起,你说的地方,是我后来改动过的,现在我把它恢复过来,问题还是一样的。login.jsp里的
    action="LoginAction" Struts.xml 里也写在class="LoginAction"
    HTTP Status 404 - /web/LoginAction--------------------------------------------------------------------------------type Status reportmessage /web/LoginActiondescription The requested resource (/web/LoginAction) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.35
      

  4.   

    <%@ page contentType="text/html; charser=gb2312" language="java" %>
    <html>
      <body>
    <form action="LoginAction" method="post">
    name:<input type="text" name="username" /><br>
    password:<input type="password" name="password"/><br>
    <input type="submit" value="submit"/>
    <input type="reset" value="reset">
    </form>
      </body>
    </html><?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="struts2" extends="struts-default">
        
         <action name="LoginAction" class="LoginAction">
         <result name="success">/hello.jsp</result>
                    <result name="failure">/error.jsp</result>
         </action>
        
         </package>
        
        </struts>
    public class LoginAction {
    private String username ;
    private String password ;
    public void setUsername(String username){
    this.username = username ;
    }
    public String getUsername(){
    return username ;
    }
    public void setPassword(String password){
    this.password = password ;
    }
    public String getPassword(){
    return password ;
    }
    public String execute() throws Exception {
    if("admin".equals(getUsername()) && "123456".equals(getPassword())){
    return "success" ;
    }else{
    return "failure" ;
    }
    }
    }但是,还是会这样HTTP Status 404 - /web/LoginAction--------------------------------------------------------------------------------type Status reportmessage /web/LoginActiondescription The requested resource (/web/LoginAction) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.35
      

  5.   

    <form action="LoginAction" method="post">
    name:<input type="text" name="username" /><br>
    password:<input type="password" name="password"/><br>
    <input type="submit" value="submit"/>
    <input type="reset" value="reset">
    </form>我靠,你的路径明显不对嘛第一种方法:
    <form action="/LoginAction" method="post">第二种方法:<!-- Struts2.0定义 -->
    <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>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/struts/*</url-pattern>
    </filter-mapping>
    <form action="/LoginAction.do" method="post">
      

  6.   

    第三种方法:<%@ taglib uri="/struts-tags" prefix="s"%><s:form method="post" action="LoginAction" namespace="" name="form1">
      

  7.   

    LoginAction   你这个是在裸包中?????
      

  8.   

    login.jsp<%@ page contentType="text/html; charser=gb2312" language="java" %>
    <html>
      <body>
    <form action="LoginAction" method="post">
    name:<input type="text" name="username" /><br>
    password:<input type="password" name="password"/><br>
    <input type="submit" value="submit"/>
    <input type="reset" value="reset">
    </form>
      </body>
    </html>