Could not read JSON: Can not deserialize instance of java.lang.Integer out of ST

Spring 会将{id:id}这个json转换成Map对象,只要将@requestBody中的参数改成Map就可以了,如下

@RequestMapping(value="/delete",method=RequestMethod.POST,produces="application/json")
@ResponseStatus(HttpStatus.OK)
public void delete(@RequestBody Map map){
this.moduleService.deleteModule(Integer.parseInt(map.get("id")+""));
}

你可能感兴趣的:(java,exception)