• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Neither BindingResult nor plain target object for bean name 'loginForm

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

 
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic