前台数据提交
$.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对象
数据提交
参考链接
https://stackoverflow.com/questions/14459171/spring-mvc-and-jquery-post-request-with-array-of-pojo