1

エラー:変換できないタイプ

私のloginActionファイルのコード:

public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception 
{
    LoginForm loginForm = (LoginForm) form;

    if (loginForm.getUserName().equals(loginForm.getPassword())) 
    {
        return mapping.findForward(SUCCESS);
    } 
    else 
    {
        return mapping.findForward(FAILURE);
    }
}

私のstruts-configファイルのコード:

<action-mappings>
    <action input="/login.jsp" name="LoginForm" path="/Login" scope="session"                type="com.strutsmyaction.LoginAction">
         <forward name="success" path="/success.jsp" />
         <forward name="failure" path="/failure.jsp" />
    </action>
</action-mappings>

ログインフォームファイルのコード

public class LoginForm {String userName; 文字列パスワード; public String getUserName(){System.out.println( "Inside getter" + userName); userNameを返します。} public void setUserName(String userName){System.out.println( "Inside setter" + userName); this.userName = userName; } public String getPassword(){パスワードを返す; } public void setPassword(String password){this.password = password; }}

4

1 に答える 1

1

私はこれがうまくいくと思う..

if (loginForm.getUserName().equals(loginForm.getPassword())) 
{
    return mapping.findForward("success");
} 
else 
{
    return mapping.findForward("failure");
}
于 2014-01-16T13:04:50.563 に答える