前台向后台传一个json数据,后台怎么接?SpringMVC有一个注解可以做到,请问是什么注解?前台怎么写代码?谢谢。
参考:http://www.cnblogs.com/quanyongan/archive/2013/04/16/3024741.html
<script type="text/javascript"> $(document).ready(function(){ var saveDataAry=[]; var data1={"userName":"test","address":"gz"}; var data2={"userName":"ququ","address":"gr"}; saveDataAry.push(data1); saveDataAry.push(data2); $.ajax({ type:"POST", url:"user/saveUser", dataType:"json", contentType:"application/json", data:JSON.stringify(saveData), success:function(data){ } }); }); </script>
@RequestMapping(value = "saveUser", method = {RequestMethod.POST }}) @ResponseBody public void saveUser(@RequestBody List<User> users) { userService.batchSave(users); }