How to Handle Error :- org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute...
I am getting error while making project: org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute...
There are following steps to solve the error and Exception code:
This is the problem while you are using Spring MVC and Hibernate using any Database like H2, Oracle, SQL and Mysql.
You need to follow the following steps as below:
1. Go to controller file and check the method with particular url that was hitted Or you can say that URL method which was accessed.
Check your Constructor of modelAndView, The MAV Object may be not binded as below.
Solution:
ModelAndView m1=new ModelAndView("User","myuser",new User());
If you have created simple model method as below:
@RequestMapping("/SignUp")
public String SignUp()
{
return "User";
}
Then, definately it will provides error as above mensioned.
You should update your code as below:
@RequestMapping(value ="/SignUp",method=RequestMethod.GET)
public ModelAndView SignUp()()
{
ModelAndView mvc=new ModelAndView("User","myuser",new User());
return mvc;
}
You should use commandName or modelAttribute on the View Page as below:
I made an USER SIGNUP Form in JSP and Started my Page with Spring Form as below:
....
@RequestMapping(value ="/SignUp",method=RequestMethod.GET)
public ModelAndView SignUp()()
{
ModelAndView mvc=new ModelAndView("User","myuser",new User());
return mvc;
}
You should use commandName or modelAttribute on the View Page as below:
I made an USER SIGNUP Form in JSP and Started my Page with Spring Form as below:
....