Hello,
I using Spring 3.2.3 with Hibernate Validator 4.3.1.
We are using default Validators (like @NotEmpty) and own ValidatorClasses for our DTOs.
Until now Hibernate Validator could get the error messages from i18n (messages_propoerties) which we registered in the applicationContext.xml.
But now we want to valid an object which was send via AJAX (JSON format). We use this method signature in the controller:
Code:
@RequestMapping(value = "/ValidateMethod")
public @ResponseBody
ArrayNode validateMethod(@Valid @RequestBody MyObjectClass myObject, BindingResult result) throws DatatypeConfigurationException {
...
}
The validation works but the messages will not be resolved. In the log I see:
Code:
Field error in object 'myObject' on field 'myField.myField ': rejected value ["ยง"];
codes [Pattern.myObject.myField.myField,Pattern.myField.myField ,Pattern.myField,Pattern.java.lang.String,Pattern];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [myObject.myField.myField,myField.myField];
arguments []; default message [myField.myField],[Ljavax.validation.constraints.Pattern$Flag;@9cd641,[0-9A-Za-z]{3,4}]; default message [must match "[0-9A-Za-z]{3,4}"]
And the validation returns then the message "must match "[0-9A-Za-z"".
In the property file I have the entry: Pattern.myObject.myField.myField=My validation message that should be displayed.
We do I not get this message? How I said, in non AJAX calls I use the same mechanism and there I get it.
Thanks for your time and help.
Greetings
hugi