• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DI is not working in my example.

 
Rahul Ba
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, I am working with SPringMVC. I am trying to use DI functionality provided by Spring, but somehow object is getting NULL value. Hence throwing NullPointerException.
My code is as follows:


Controller is as follows:




I am getting null pointer exception because:


Is LoginService Null3:NULL;















PLease tell me where I am wrong and why I am getting null.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set your property "loginService" on your bean "/login.html"
 
Rahul Ba
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom, Thanks for looking into this. but I do not get where to set the loginService bean.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add <property name="loginService" ref="loginService" /> to your /login.html bean. Follow the pattern of your viewResolver bean to add the property.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic