I am getting this error continuously ,I have seen earlier posts in stackoverflow similar to this one but I was not able to figure out how to map commandName with my controller class. What is the real use of commandName.
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'student' available as request attribute
Register.jsp
<form:form class="form-horizontal" style="margin-top: 45px"
action="registeration.do" method="post" commandName="student">
<div class="form-group row">
<div class="col-9 col-sm-offset-2 col-lg-8">
<form:input type="text" class="form-control" id="email"
placeholder="Enter email" path="email"/>
<form:errors path="email" cssClass="error" />
</div>
</div>
<div class="form-group row">
<div class="col-9 col-sm-offset-2 col-lg-8">
<form:input type="password" class="form-control" id="password"
placeholder="Enter password" path="password" />
<form:errors path="password" cssClass="error" />
</div>
</div>
<div class="form-group row">
<div class="col-9 col-sm-offset-2 col-lg-8">
<form:input type="text" class="form-control" id="name"
placeholder="Enter name" path="name"/>
<form:errors path="name" cssClass="error" />
</div>
</div>
StudentController.java
@Controller
public class StudentController {
@RequestMapping(value="registeration.do" ,method=RequestMethod.POST)
public ModelAndView submitAdmissionForm(@Valid @ModelAttribute("student") Student student,BindingResult result,ModelMap model)
{
System.out.println("Implementing the Validations");
Map <String,Object> modelMap=new HashMap<String,Object>();
modelMap.put("student", student);
if(result.hasErrors())
{
System.out.println("error is there");
return new ModelAndView("Registeration",modelMap);
}
else{
return new ModelAndView("AdmissionSuccess",modelMap);
}
}
}
}