I have a <form:options> in my jsp for which I have defined the path attribute. It looks like this
<form:select id="drpDwn" path="usrNm" onchange="getUserNames()">
My Controller method signature looks like this, I am just calling my service method to populate the user names
@RequestMapping(value="/usrForm", method = RequestMethod.GET, headers="Accept=application/json")
public @ResponseBody JSONArray getUserNames(@RequestParam("userId") Integer userId, OutputStream opStream){
return usrService.getUserNames(userId, opStream);
}
When I am submitting the page I am getting the error
Neither BindingResult nor plain target object for bean name 'usrNm' available as request attribute
I looked up the forum and found that I have to define the Model Attribute , but I have not understood the root cause of this issue.
Can anybody please list it down , and explain that what is it exactly that Spring is looking for
the form expects a bean called
usrNm. Whichever controller directs to the page with the form should set that bean.The controller you show is for processing the form (I assume), however it is the code that returns the view with the form on that is causing the error.