使用Spring框架..和Jackson将Json映射到类..
{name:'abc', marks:'100'}
-
class student{
String name;
int marks;
}
-
现在这已正确映射...但是,如果我将JSON修改为
{name:'abc', marks:'ten'}
org.springframework.http.converter.HttpMessageNotReadableException:无法读取JSON 异常被抛出... 现在,我需要捕获此异常并返回一些结果。如何捕捉异常。
这是控制器:
@RequestMapping(value="xxxxxx",produces="application/json",method=RequestMethod.GET)
public @ResponseBody String mymethod(@RequestBody Student studentData, HttpServletResponse response,
HttpServletRequest request)
{
//controller code
}