Reputation: 49
Error: inconvertible types
my loginAction file's code:
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);
}
}
my struts-config file's code:
<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>
my loginform file's code
public class LoginForm { String userName; String password; public String getUserName() { System.out.println("Inside getter "+userName); return userName; } public void setUserName(String userName) { System.out.println("Inside setter "+userName); this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
Upvotes: 1
Views: 518
Reputation: 255
I think This will work ..
if (loginForm.getUserName().equals(loginForm.getPassword()))
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("failure");
}
Upvotes: 1