用STRUTS2写了一个login小程序,运行时出现如下错误,请高手指点!!!看看可能是哪出错了。
HTTP Status 500 -type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.

解决方案 »

  1.   

    你请求的资源有问题
    你的action或者是配置有问题
      

  2.   

    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="default"  extends="struts-default">        
            <action name="login" class="LoginAction">
                <result name="success">/success.jsp</result>
                <result name="error">/error.jsp</result>                        
            </action>
        </package>   
    </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/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>    <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    </web-app>
    登陆页面信息login.jsp:
    <%@ page contentType="text/heml;charset=GBK" %>
    <html>
    <head>
    <title>登陆页面</title>
    </head>
    <body>
    <form action="login.action" method="post">
    <table>
    <tr>
    <td>请输入用户名:</td>
    <td><input type="text" name="user.username"></td>
    </tr>
    <tr>
    <td>请输入密码:</td>
    <td><input type="password" name="user.password"></td>
    </tr>
    <tr>
    <td><input type="reset" value="重填"></td>
    <td><input type="submit" value="提交"></td>
    </tr>

    </table>
    </form>
    </body>
    </html>
    error页面信息error.jsp:
    <%@ page contentType="text/html; charset=GBK"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head><title>登录失败!</title></head>
    <body>
    用户密码错误,请重新<a href="login.jsp">登陆</a>
    </body>success页面信息success.jsp:
    <%@ page contentType="text/html;charset=GBK"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head>
    <title>欢迎页面</title>
    </head>
    <body>
    <h3><s:property value="user.username" /></h3>
    </body>
    </html>
    java类信息:
    LoginAction.java:

    import com.opensymphony.xwork2.Action;
    public class LoginAction implements Action {
    private User user; public String execute() throws Exception {

    if("wangshengpeng".equals(user.getUsername())
    && "wsp".equals(user.getPassword()))
    return SUCCESS;
    else 
    return ERROR;
    }
    public User getUsername(){
    return user;
    }
    public void setUser(User user){
    this.user=user;
    }
    }</html>
    User.java:
    import java.io.Serializable;
    public class User implements Serializable {
    private String username;
    private String password;
    public String getUsername(){
    return username;
    }
    public void setUsername(String username){
    this.username=username;

    }
    public String getPassword(){
    return password;
    }
    public void setpassword(String password){
    this.password=password;
    }
    }
      

  3.   

    LoginAction没有getUser()方法
    你的是getusrename方法 
      

  4.   

    public User getUsername(){
    return user;
    }
    public void setUser(User user){
    this.user=user;
    }
    }
    看红色部分! get/set后面保持一致
      

  5.   

    看你页面上的为user.username,那么应该把getUsername改成getUser
      

  6.   

    1.  LoginAction   中  public User getUsername(){
    return user;
    }应该 为 :
    [code=Java]
    public User getUser(){
    return user;
    }
     
    2. struts.xml 中  class="LoginAction" 要注意将 包名也一并的添上
      

  7.   

    有可能人家就是没包名, 也有可能是Spring管理的.!  当然不排除出错的可能.! getUser是太明显了
      

  8.   

    struts.xml 文件中class应该把包名也加上
    class="com.opensymphony.xwork2.Action.LoginAction"