BindingResult.rejectValue does not find value from ValidationMessages.properties
We are using spring with annotations and our annotated fields are validated correctly and error messages show up in ValidationMessages.properties, but the custom validation message from ValidationMessages.properties doesn't seem to be used.
Here's an example:
Validatior (also form):
public void validateSpecial(BindingResult result) {
if(password != null && !password.equals(passwordConfirm)){
result.rejectValue("passwordConfirm", "emailform.passwordConfirm.passwordsDontMatch", new Object[]{}, "This message is in the code.");
...}
ValidationMessages.properties:
... emailform.passwordConfirm.passwordsDontMatch = Passwords don't match ...
Controller:
...
form.validateSpecial(result);
if (result.hasErrors()) {
return "/path/to/input/page";
}
...
The error I receive is "This message is in the code", not "Passwords do not match"
+2
a source to share
1 answer