• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Neither BindingResult nor plain target object for bean name 'loginForm

 
Geeta Puttappanavar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You so much Rakesh.. I got output.

 
Dushyant Chhetri
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic