1.前台
var ids = [];
for(var i=0; i<10; i++){
person = new Object();
person.id = i;
person.name="123";
ids.push(person );
}
$.ajax({
type: 'post',
dataType: 'json',
url: '/test/sendList',
data: {"ids":JSON.stringify(ids)},
contentType:"application/json",//这一步可能导致springMVC无法通过@RequestParam和request.getParameter接收
success: function (result) {
console.log(result)
},
error: function(data){
alert("操作异常");
}
});
2,后端接收
@PostMapping("/sendList")
@ResponseBody
public Map<String,Object> sendList(Model model,HttpServletRequest request,@RequestParam