3

Jackson 解析List<Long>List<Integer>,因此我得到一个ClassCastException. 解决方案之一是将参数作为 aList<String>但我不想这样做。有人可以建议我一个替代方案吗?

@RequestMapping(value = "/device/deleteNote", produces = "application/json", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<?> deleteNotification(@RequestBody ArrayList<Long> notificationIdListParam) {
    ....
}
4

1 回答 1

5

尝试这个

final static ObjectMapper mapper = new ObjectMapper();

final List<Obj> instance = mapper.readValue(json, new TypeReference<List<Obj>>(){});
于 2013-09-16T09:34:17.067 回答