• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Neither BindingResult nor plain target object for bean name 'loginForm

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

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic