1. 程式人生 > >java後臺接收json資料,報錯com.alibaba.fastjson.JSONObject cannot be cast to xxx

java後臺接收json資料,報錯com.alibaba.fastjson.JSONObject cannot be cast to xxx

  從前臺接收json封裝的list資料,在後臺接收時一直報錯,com.alibaba.fastjson.JSONObject cannot be cast to xxx,

  使用這種方式接收可以接收

 1 @RequestMapping(value = "/insertUser", method = RequestMethod.POST)
 2 public ResultT insertUser(@RequestBody Map<String,List<User>> map){
 3     List<User> userList = map.get("insertUserList");  
4 } 5 6 //前臺json格式 7 { 8 "insertUserList": [ 9 { 10 "firstName": "Brett", 11 "lastName": "McLaughlin", 12 "email": "aaaa" 13 }, 14 { 15 "firstName": "Jason", 16 "lastName": "Hunter", 17 "email": "bbbb" 18
}, 19 { 20 "firstName": "Elliotte", 21 "lastName": "Harold", 22 "email": "cccc" 23 } 24 ] 25 }