I am using Spring MVC 3.2.4. I have a controller method that gets data from an HTML form. The method has the following signature:
@RequestMapping(...)
public String updateProduct(@Valid Product product, BindingResult bindingResult)
In the method, I can get information about data binding (for example, a non-integer value in an integer field) and verification (JSR-303) as follows:
if (bindingResult.hasErrors()) {
List<FieldError> errors = bindingResult.getFieldErrors();
for (FieldError error : errors) {
System.out.println(error.getObjectName() + " - " + error.getCode());
}
}
I want to change this method so that it can receive data in JSON format instead application/x-www-form-urlencoded. I added an annotation @RequestBodyto the method signature:
@RequestMapping(...)
public String updateProduct(@Valid @RequestBody Product product, BindingResult bindingResult)
. HttpMessageNotReadableException. , , , /. , JSR-303, JSR-303 .
, JSON?
UPDATE:
, , Product String, JSR-303. , . Product .