Back Forum Reply New

args in messages.properties not showing

I am getting
This {0} and that {1} cannot be empty or have whitespace only.

instead of
This arg1 and that arg2 cannot be empty or have whitespace only.

Any thoughts?Validator.java:

Code:
public void validate(Object command, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, quot;fieldNamequot;, quot;error.emptyOrWhitespacequot;, new Object[] { quot;arg1quot;, quot;arg2quot; }, quot;Default message.quot;);
}
messages.properties:

Code:
error.emptyOrWhitespace=This {0} and that {1} cannot be empty or have whitespace only.
JSP:

Code:
lt;spring:hasBindErrors name=quot;commandquot;gt;
lt;div id=quot;bindErrorsquot;gt;
lt;c:forEach var=quot;itemquot; items=quot;${errors.allErrors}quot;gt;
lt;span class=quot;errorquot;gt;lt;spring:message code=quot;${item.code}quot; text=quot;${item.defaultMessage}quot; /gt;lt;/spangt;lt;br /gt;
lt;/c:forEachgt;
lt;/divgt;
lt;/spring:hasBindErrorsgt;Try this:

Code:
lt;spring:bind path=quot;command.*quot;gt;
lt;c:if test=quot;${not empty status.errorMessages}quot;gt;
lt;pgt;There were error(s):lt;/pgt;
lt;ulgt;
lt;c:forEach var=quot;errorquot; items=quot;${status.errorMessages}quot;gt;
lt;ligt;
lt;cut value=quot;${error}quot; escapeXml=quot;falsequot;/gt;
lt;/ligt;
lt;/c:forEachgt;
lt;/ulgt;
lt;/c:ifgt;
lt;/spring:bindgt;
¥
Back Forum Reply New