I am having trouble receiving my confirmation message.
I searched and read over the Internet and SO for several hours, I want to associate a question with a marked answer Configure spring validation error
I have a MessageSource bean, and message.properties reads it correctly, since I also use it for plain text, which will be displayed using th:text="#{some.prop.name} , which works absolutely fine. It's just a validation error that will not work as it should.I am sure that this is a stupid error that I just forget ... The verification itself works reliably.
Constraint:
@NotEmpty(message="{validation.mail.notEmpty}") @Email() private String mail;
messages.properties:
Part of the template:
<span th:if="${#fields.hasErrors('mail')}" th:errors="*{mail}"></span>
Display Text:
{validation.mail.notEmpty}
I tried many variations, all without success.
@NotEmpty(message="validation.mail.notEmpty") @NotEmpty(message="#{validation.mail.notEmpty}")
Will show the exact value of the message line, indiscriminately.
<span th:if="${#fields.hasErrors('mail')}" th:errors="${mail}"></span> <span th:if="${#fields.hasErrors('mail')}" th:errors="#{mail}"></span> <span th:if="${#fields.hasErrors('mail')}" th:errors="#{*{mail}}"></span> <span th:if="${#fields.hasErrors('mail')}" th:errors="#{__*{mail}__}"></span>
will result in an error.
EDIT:
After debugging, I came across this:
Class: org.springframework.context.support.MessageSourceSupport
Method: formatMessage(String msg, Object[] args, Locale locale)
will be called using
formatMessage("{validation.mail.notEmpty}", null, locale /*German Locale*/)
And it will run in if (messageFormat == INVALID_MESSAGE_FORMAT) {
So ... my message format is incorrect. This is a way out of my volume / knowledge. Does anyone know what that means?