前端代码:
let data = new Array();
this.rowSelection.selectedRowKeys.forEach(element => {
data.push(this.dataSource[element]);
});
postAction(this.url.reqUrl,{data}).then((res) => {
if (res.success) {
this.$message.success("操作成功");
} else {
this.$message.warning(res.message);
}
this.selectedRowKeys.length=0;
});
后端代码:
@RequestMapping(value = "/reqUrl")
public Result<?> method(@RequestBody String req) {
JSONObject jsonObject = JSONObject.parseObject(req);
//对象转换为json字符串
String dataInfo = String.valueOf(jsonObject.get("data"));
//json字符串转换为List<T>
List<T> list = JSONArray.parseArray(dataInfo, T.class);
log.info("list:"+list);
Result<?> res= service.function(list);
return res;
}