2
votes

My web page has a lot of horizontal space next to the fields that are being validated and I want to show all validation errors for one field, separated by a comma.

Currently a typicaly multiple spring error messages are being formatted into html like that:

<input id="name" type="text" size="50" value="" name="name"></input>
    <span id="name.errors" class="errText">
       Name cant be blank!
       <br></br>
       Name is required!
    </span>

What I want is to specify a format(ter) which would output an error message like this:

<input id="name" type="text" size="50" value="" name="name"></input>
    <span id="name.errors" class="errText">
       Name cant be blank!, Name is required!
    </span>

Is it possible to do this globally or at least with initBinder method per controller?

Thanks.

2

2 Answers

0
votes

You can format error like you want with that code :

<spring:bind path="YourFieldPath">
    <c:forEach var="error" items="${status.errorMessages}" varStatus="status">
        ${error}
        <c:if test="${!status.last}">,</c:if>
    </c:forEach>
</spring:bind>
0
votes

You can use display: inline in CSS