Spring MVC Error Messages
Hello Spring Fellows,
I have a form that is validated using Spring Validation after submitting. Each field of the form may contain several error messages if verification is not performed, therefore error messages are displayed below the field and not next to it. Here is a snippet of code.
<tr> <td><form:input path="name" /></td> </tr> <tr> <td> <form:errors path="name*" /> </td> </tr>
Note that there is an asterisk at the end of the path value indicating that all error messages for name should be displayed.
As you can see, the problem is that if there is no error message, the page will have an extra line that looks out of place for the user. The above code is a too simplified version, so there is a lot more material in the code itself, which prevents me from moving the <form:errors> tag inside the tag containing this field.
Is there a way to find out if there is any message associated with this path at the JSP level? Basically, I would like to do the following:
<c:if test="${what do I write here?}"> <tr> <td> <form:errors path="name*" /> </td> </tr> </c:if>
Thanks!
java spring spring-mvc
Tom tucker
source share