杰克逊将List<Long>
解析为List<Integer>
,因此我得到ClassCastException
。其中一个解决方案是将参数作为List<String>
,但我不想这样做。有人可以建议我另类吗?
@RequestMapping(value = "/device/deleteNote", produces = "application/json", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<?> deleteNotification(@RequestBody ArrayList<Long> notificationIdListParam) {
....
}
答案 0 :(得分:5)
试试这个
final static ObjectMapper mapper = new ObjectMapper();
final List<Obj> instance = mapper.readValue(json, new TypeReference<List<Obj>>(){});