PDA

View Full Version : how to diaplay all errors using the spring tag lib


sjivan
Nov 29th, 2004, 06:29 AM
Normally one includes the following in a JSP to diplay all binding error for a given command bean.


<spring:bind path="command.*">
<c:forEach var="error" items="${status.errorMessages}">
<p><font color="red"><c:out value="${error}"/></font><p>
</c:forEach >
</spring:bind>


However I'd like to move this out of each JSP into a Sitemesh template so I was wondering if there was a way to display all binding errors, without knowing the "command" name that was used in each JSP.

Although the snippet below where I specify path="*.*" does not work with Spring, I would like to get the equivalent results.


<spring:bind path="*.*">
<c:forEach var="error" items="${status.errorMessages}">
<p><font color="red"><c:out value="${error}"/></font><p>
</c:forEach >
</spring:bind>



I could use scriptlets and manually search for request attributes starting with "org.springframework.validation.BindException." but was wondering it there was a more elegant way.

Thanks,
Sanjiv