I need to do something like that:
<form:errors path="*">
<div class="error">
<div class="internal">
<a href="#" class="close"></a>
${error}
</div>
<div class="bar"> </div>
<div class="internal">
<input type="button" value="Ok" />
</div>
</div>
</form:errors>
How can I get all the error messages by using the above HTML code? :S
By using <form:errors path="*" cssClass="error" />
it will be inside only one tag
You can use the spring:bind tag to bind a status-variable to your current error messages. Then you can iterate over status.errorMessages like in the example below.
<spring:bind path="*">
<c:forEach items="${status.errorMessages}" var="error">
<div class="error">
<div class="internal">
<a href="#" class="close"></a>
${error}
</div>
<div class="bar"> </div>
<div class="internal">
<input type="button" value="Ok" />
</div>
</div>
</c:forEach>
</spring:bind>
Don't forget to add the taglib declaration for spring: tags on top of your page:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With