SpringBoot前端给后端传list

前端JS

 1 var taskList = ["123","456"];
 2 var params = {
 3     taskList: taskList
 4 };
 5 
 6 $.ajax({
 7     type: "PUT",
 8     dataType: "json",
 9     url: "/client/update",
10     data: params,
11     success: function (msg) {
12     }
13 });

后端接收:

1 @RequestMapping(value = "/update", method = RequestMethod.PUT)
2     @ResponseBody
3     public JSONResult updateClient(Client client, @RequestParam(value = "taskList[]") List<String> taskList) {
4         logger.debug("Yufan taskList={}", taskList);
5         return JSONResult.ok();
6 }

参考文献:spring MVC 前台传数组类型,后台用list类型接收也是可以的

猜你喜欢

转载自www.cnblogs.com/yfzhou/p/9661994.html