欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java后台接收json数据,报错com.alibaba.fastjson.JSONObject cannot be cast to xxx

程序员文章站 2022-06-21 16:44:44
从前台接收json封装的list数据,在后台接收时一直报错,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 }