Neither BindingResult nor plain target object for bean name ‘command’ available as request

Problem:

A JSP with spring form is not rendered properly.

<form:form action=”add_expense”>
<form:label path=”expenseDate”>Expense Date</form:label>
<form:input path=”expenseDate” />
<input type=”submit” />
</form:form>

28-1406551309-touristplaces

Error Message:

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ‘command’ available as request attribute

Solution

I set the request attribute in a different name in the Controller bean.

modelAndView.addObject(“expenseDetail”, new ExpenseDetail());
return modelAndView;

I set the required parameter by name expenseDetail. Hence the form tag was re-written as given below.

<form:form action=”add_expense” commandName=”expenseDetail”>

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top