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”>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s