Using Spring framework.. and Jackson to map Json to classes..
{name:'abc', marks:'100'}
-
class student{
String name;
int marks;
}
-
Now this is getting mapped properly... But, if i modify JSON to
{name:'abc', marks:'ten'}
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON exception is thrown... Now, i need to catch this exception and return some result. How to catch the exception.
Here is the controller:
@RequestMapping(value="xxxxxx",produces="application/json",method=RequestMethod.GET)
public @ResponseBody String mymethod(@RequestBody Student studentData, HttpServletResponse response,
HttpServletRequest request)
{
//controller code
}