views:

2624

answers:

3

I work with a front-end developer who writes JSP files. We have a form that is working correctly, except validation/binding/processing errors can't seem to be displayed with Spring's <form:errors/> tag.

I've confirmed that the error is being set, and what is apparently the correct path for the errors. Supposedly <form:errors path="*" /> should render them all, regardless of path, but it shows nothing.

Do I need to get into the tag library source to deduce what's going wrong?

+1  A: 

Simple answer: <form:errors/> must be within a <form:form/> element in order to bind to the model's "command" object.

Mojo
A: 

doesnt seem to be working for me even though its inside . Could you please help me out.

Thanks in advance.

A couple of things I discovered. Make sure your form command object is using the model key "command". Then make sure your errors are being added using the .reject* methods, and not the .addError methods. When I used .addError, they never appeared in <form:errors/>
Mojo
+1  A: 

2 things I discovered.

1) make sure you specify the name of the form-bean / command object in the form tag

<form:form method="post" enctype="multipart/form-data" commandName="salesOrder">

2) make sure you name your form-bean / command object by its class name. In the example above my class is com.abc.xyz.SalesOrder. If I call it "so" or "order" in the model then it will not show the errors.

Derek