I was looking around the net for this. Maybe I didn’t look hard enough but I wasn’t able to find it. Finally a coworker told me. If you use the SpringMVC framework and wish to show generic validation error messages at the top of the page, here’s how you do it:
<spring:hasBindErrors name="formName">
<div class="genericErrors">
<span class="errorRight">
<c:choose>
<c:when test="${errors.errorCount > 1}">
There are ${errors.errorCount} errors. Please correct them.
</c:when>
<c:otherwise>
There is ${errors.errorCount} error. Please correct it.
</c:otherwise>
</c:choose>
Scroll down if necessary to see all of the error messages in red.
</span>
</div>
</spring:hasBindErrors>
Obviously if you wish to display specific error for a field, you’d use
<form:errors path="yourInputName" />
To read more about error handling in SpringMVC, read the chapter 13 of its documentation.