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 }
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册⭐️ Admin快速开发: https://show.cool-admin.com/
赞 0⭐️ 官方文档: https://cool-js.com
赞 0⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld
赞 0