这是前端的数据结构
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("保存网格项目关联信息成功");}