How can we display form errors out side of form. I know it can be displayed inside of form using <sf:errors path="nb"></sf:errors>
. If I want to display it in separate div
how can I do it? I am new to spring so please guide me.
You could, if you're planning to display all error messages simultaneously, using the following taglib.
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
Something like,
<spring:hasBindErrors htmlEscape="true" name="someBean">
<c:if test="${errors.errorCount gt 0}">
<h4>The error list :</h4>
<font color="red">
<c:forEach items="${errors.allErrors}" var="error">
<spring:message code="${error.code}"
arguments="${error.arguments}"
text="${error.defaultMessage}"/><br/>
</c:forEach>
</font>
</c:if>
</spring:hasBindErrors>
Note that the name attribute name="someBean"
of the tag <spring:hasBindErrors/>
is your actual command object which is bound to your form.
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