I am using JSON binding as following in my controller
public @ResponseBody Person getPerson(@RequestBody PersonReq req){
// Some code here..
....
}
If for some reason the JSON request sent is invalid, then spring throws a very generic error. Will I be able to gracefully handle this error?
What I want to do is something similar to form databinding where you can use BindingResult to capture the errors. (as shown below)
public String getPersonHtml(PersonReq req, BindingResult result){
if (result.hasErrors()){
// do error handling here..
}
}
I tried similar approach by providing additional argument (BindingResult) but that didnt help.
Use Fiddler to confirm that the JSON request is valid.