学无先后,达者为师

网站首页 编程语言 正文

前端传递对象数组,后端使用list接收并解析

作者:前端开心果 更新时间: 2023-08-01 编程语言

使用环境:前端 vue + axios,后端 springBoot
前端

save() {
    const data = [] // 图片对象数组
    data.push({
        gpGid: this.gId,
        gpAddress: this.imgList[0],
        gpIsCover: 1,
    })
    this.$axios({
        url: 'goodsPicture/save',
        method: 'post',
        dataType: 'json',
        data: JSON.stringify(data),
        headers: {
            'Content-Type': 'application/json',
        },
    }).then(res => {
        if (res.data.code === 200) {
            console.log(res.data)
        }
    })
    .catch(error => {
        console.log(error)
    })
}

后端

@PostMapping(value = "/save")
@RequiresRoles("business")
public MyResult save(@RequestBody List<GoodsPicture> goodsPictureList) {
    System.out.println("我进来了");
}

原文链接:https://blog.csdn.net/qq_38157825/article/details/105291362

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新