SpringMVC @RequestBody 接收Json数组对象
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type:'POST',
url:'<%=path%>/user/ceshi.do',
dataType:"json",
contentType:"application/json",
data:JSON.stringify([{id:"1",name:"cehshi1"},{id:"2",name:"ceshi2"}]),
success:function(){
} });
</script>
@RequestMapping(value = "/ceshi", method = {RequestMethod.POST })
@ResponseBody public void ceshi(@RequestBody User[] users){
for (User user : users) {
System.out.println(user.getId());
} }
注:后台用对象数组接收User[] users 不要用List<T> list只支持简单属性类型