码迷,mamicode.com
首页 > 编程语言 > 详细

SpringMVC @RequestBody接收Json对象字符串

时间:2016-09-27 11:33:59      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

JavaScript 代码:

技术分享
<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> 
技术分享

Java代码

    @RequestMapping(value = "saveUser", method = {RequestMethod.POST }}) 
    @ResponseBody  
    public void saveUser(@RequestBody List<User> users) { 
         userService.batchSave(users); 
    } 

SpringMVC @RequestBody接收Json对象字符串

标签:

原文地址:http://www.cnblogs.com/qq3111901846/p/5911998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!