$.ajax提交数组到SpringMVC

前台数据提交

$.ajax({
                'type': 'POST',
                'url':"${pageContext.request.contextPath}/web/${webId}/menu/saveList",
                'contentType': 'application/json',
                'data': JSON.stringify(menu.menuList),
                'dataType': 'json',
                success: function(data) {

                }
            });

后台数据接收

    @PostMapping("/saveList")
    @ResponseBody
    public ResponseDTO saveList(@RequestBody List<MenuDto> menuDtoList) {
        menuService.saveList(menuDtoList);
        return response(menuDtoList.size());
    }

@RequestBody会通过jackson将json字符串转化成java对象

数据提交

http://xhope.top/wp-content/uploads/2017/08/1.png

参考链接
https://stackoverflow.com/questions/14459171/spring-mvc-and-jquery-post-request-with-array-of-pojo