给后台SpringMVC传递数组

给后端传递List参数

1、把数组用JSON.stringify方法变为json字符串

var requestBody = JSON.stringify(window.roleIdArray);

2、后台接受代码

@ResponseBody
@RequestMapping("/role/remove/by/role/id/array.json")
public ResultEntity<String > deleteRole(@RequestBody List<Integer> roleIdList) {
    roleService.deleteRoles(roleIdList);
    return ResultEntity.successWithoutData();
}
原文地址:https://www.cnblogs.com/Adam-Ye/p/13353739.html