Spring MVC – Neither BindingResult nor plain target object for bean name ‘xxx’ available as request attribute.
Problem
Recently, just converted the Spring MVC xml-based form controller to annotation-based form controller, and hits the following error message.
SEVERE: Neither BindingResult nor plain target object for bean name ‘customerForm’ available as request attribute
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ‘customerForm’ available as request attribute
Above error message is clearly indicated that the “customerForm” bean is not exists, and i 100% sure the view resolver is configured properly and the “CustomerForm.jsp” view page is existed.
Form Controller
@Controller @RequestMapping("/customer.htm") public class CustomerController{ @RequestMapping(method = RequestMethod.GET) public String initForm(ModelMap model){ //return form view return "CustomerForm"; }
View Resolver
... <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name="prefix"> <value>/WEB-INF/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean>
Solution
The root caused is the incorrect view name in JSP page, see below.
<form:form method="POST" commandName="customerForm">The “customerForm” is not exists in the controller mapping anymore, see annotation mapping @RequestMapping(“/customer.htm”), it should change to “customer”.
<form:form method="POST" commandName="customer">Similar Cases
I’ve seen quite many similar cases happened in validator or SimpleFormController class as well. To solve it, just make sure the mapping name is matched or existed.






Thank you mkyoung! :) I Just had a similar problem and this helped me out.
BTW are you sure that it is because of @RequestMapping(“/customer.htm”) that it should be: . It would be much simpler if it was a mapping to @ModelAttribute(“customer”) for example.
I am not sure which one it is, since in my case the names are the same.
After some tests I am sure that it is commandName=”customer” because of @ModelAttribute(“customer”) and not @RequestMapping(“/customer.htm”).
But still thanks since you lead me in the right direction with the commandName attribute. And then also because of all your nice tutorials, which I have learned alot from in the last 6 month. The date I found it :)
Good to know that mkyong.com tutorials, did help you in some ways :)
Thank you, I was confusing the ‘commandName’ attribute
Did the same as you tole bust still problem coming??
“Neither BindingResult nor plain target object for bean name ‘xxx’ available as request attribute”
Means you are requesting something that doesn’t exist, your case may not in JSP, it may inside your class or somewhere else. Try find where’s your requested object from and did it spell correctly.