| Author |
Neither BindingResult nor plain target object for bean name 'loginForm
|
Geeta Puttappanavar
Ranch Hand
Joined: Jan 18, 2012
Posts: 34
|
|
Hi,
I'm new to Spring. Trying to develop a small login application. But I' getting the exception. Here is my code & exception
here is the exception
Please help me. since from 4 days I'm trying but no use.
Thanks,
Geeta
|
 |
Rakesh Basani
Ranch Hand
Joined: Jun 04, 2012
Posts: 38
|
|
Hi geetha,
you cann't get loginForm object from the request.. You should get it by using @ModelAttribute("loginForm") annotation..
Repalce your loginAction() method with below code..
public String loginAction(@Valid @ModelAttribute("loginForm") LoginForm login, BindingResult errors) {
///LoginForm login=new LoginForm()----> for this loginform will get null;
System.out.println("<-----loginAction---->"+errors);
boolean status=loginDao.aunthenticateUser(login);
if(errors.hasErrors()){
return "Login";
}
else if(status==false){
errors.rejectValue("userName", "invalid.user");
return "Login";
}
else
return "welcome";
}
In this case, loginForm object from the jsp page automatically stored into the login object of loginAction() method parameter..
|
 |
Geeta Puttappanavar
Ranch Hand
Joined: Jan 18, 2012
Posts: 34
|
|
Thank You so much Rakesh.. I got output.
|
 |
Dushyant Chhetri
Ranch Hand
Joined: Oct 28, 2009
Posts: 75
|
|
Hi Geeta, Rakesh,
I am having a similar problem.
I am using the Spring validator but getting exactly the same error Geeta was getting earlier.
I have tried the solution advised by Rakesh but in vain.
PLEASE HELP..
|
 |
Rakesh Basani
Ranch Hand
Joined: Jun 04, 2012
Posts: 38
|
|
Hi Dushyant,
Its been long time since I leave the Spring. But as far as I remember, you should use the same name to get the value from request.
I replaced the login name with loginForm in public String processLogin(-,-) method.
|
 |
 |
|
|
subject: Neither BindingResult nor plain target object for bean name 'loginForm
|
|
|