Issue
model.addAttribute("error",ErrorMessages.USERLOGINERROR);
is not working while using redirect
return "redirect:/userlogin";
I have google it but not found approciate answer
if(name.equals("false")){
System.out.println(ErrorMessages.USERLOGINERROR);
model.addAttribute("error",ErrorMessages.USERLOGINERROR);
return "redirect:/getuserloginpage";
}
JSP:
<form:form action="userlogin" method="post" commandname="login">
<div align="center" style="color: red">${error}</div>
<div align="center" style="color: red">${thanks}</div>
...
expected result should be :
Please check your email or password. actual results : printed nothing. (no error or exception found)
Solution
Do one thing, you are using
return "redirect:/userlogin";
it means you have
@RequestMapping(value="/userlogin", method=GET)
public String yourMethod(Model model)
{
your code.....
return some_page_name;// from tiles.xml or directly as per you configuration
}
now use the same return
if(name.equals("false")){
System.out.println(ErrorMessages.USERLOGINERROR);
model.addAttribute("error",ErrorMessages.USERLOGINERROR);
//return "redirect:/getuserloginpage";
return some_page_name; // simple and easy but take care of functionality
}
Answered By - Satish Verma