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只支持简单属性类型
带着疑问去思考,然后串联,进而归纳总结,不断追问自己,进行自我辩证,像侦查嫌疑案件一样看待技术问题,漆黑的街道,你我一起寻找线索,你就是技术界大侦探福尔摩斯