Actually, <form:errors> does use MessageFormat, but only if you pass in arguments. Note that the javadoc for the Errors.rejectValue() which takes the errorArgs parameter says this:
errorArgs - error arguments, for argument binding via MessageFormat (can be null)
It's no different with <spring:message>. An example:
From the resource bundle:
Code:
phrase1.msg=This is the {0}th user''s message. It's very short.
phrase2.msg=This is some user''s message. It's very short.
From the html:
HTML Code:
<spring:message code="phrase1.msg"/><br/>
<spring:message code="phrase1.msg" arguments="5"/><br/>
<spring:message code="phrase2.msg"/><br/>
<spring:message code="phrase2.msg" arguments="5"/><br/>
This results in:
Code:
This is the {0}th user''s message. It's very short.
This is the 5th user's message. Its very short.
This is some user''s message. It's very short.
This is some user's message. Its very short.
This seems inconsistent to me. In our application, we have some messages that get arguments passed into them, others which don't. So the resource bundle has to have a mix of double-quoted and single-quoted apostrophes. Something like this:
Code:
error.user.general.firstname=User's first name is required.
error.user.specific.firstname=User #{0}''s first name is required.