How to print global errors only with form: errors?

In my form, I have some specific target errors (with path="myField" ), and I would like to reset global errors because they span multiple fields.

But if I use <form:errors path="*"> , it will print global AND retype local errors!

How can I print only global?

+7
source share
3 answers

As far as I remember, to do this, use <form:errors /> without the path attribute.

+9
source

I am not sure about using the form tag for this. But the Errors object has methods for getglobalerrors .

EDIT

  <spring:hasBindErrors name="input"> <c:forEach items="${errors.globalErrors}" var="errorMessage"> <div id="errors" class="errors"> <c:out value="${errorMessage.defaultMessage}" /> </div> </c:forEach> </spring:hasBindErrors> 
+4
source

The lack of a path does not work, you must insert an empty path:

 <form:errors path=""/> 
0
source

All Articles