post给后端传递数组和多个参数

编程入门 行业动态 更新时间:2024-10-10 02:23:43

post给后端传递数组和<a href=https://www.elefans.com/category/jswz/34/1771377.html style=多个参数"/>

post给后端传递数组和多个参数

        这是前端的数据结构 

  data() {return {loading: false,inputForm: {id: '${gridProject.id}',gridName: '',gridId: '',projectName: '',projectId: '',type: ''},data: [],value: []}},

        其中 gridId 和 type 是单个参数 , value 是个数组注意 这里data中的value[]不要直接给后端传过去,需要转接下再发送过去

// 提交
doSubmit(call) {let value = this.valuelet type = this.inputForm.typethis.post('${ctx}/basicinfo/gridProject/save?gridId=' + this.inputForm.gridId + '&type=' + type, value).then((res) => {if (res.success) {this.$message.success(res.msg)call()} else {this.$message.error(res.msg)}})
}

        后端做接受时需要添加 @RequestBody 和 @RequestParam注解区分前端传来的数据

    /*** 保存网格项目关联信息**/@ApiOperation("保存")@ResponseBody@PostMapping(value = "save")public AjaxJson save(@RequestBody @RequestParam("gridId") String gridId,@RequestBody String[] value,@RequestBody @RequestParam("type") String type) throws Exception {gridProjectService.saveProject(gridId,value,type);return AjaxJson.success("保存网格项目关联信息成功");}

 

更多推荐

post给后端传递数组和多个参数

本文发布于:2023-11-17 04:38:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640136.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   数组   后端   参数   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!