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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM