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

servlet解析post传递的json数组字符串

时间:2015-06-03 19:40:06      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:json数组字符串   gson   

1、js代码:

    var workData = [];
    // 添加元素
    workData.push({'pk':'1','name':'1x'});
    workData.push({'pk':'2','name':'2x'});
    workData.push({'pk':'3','name':'3x'});
    workData.push({'pk':'4','name':'4x'});
    
    $.post('/hospital1/entry/poActions.jsp', 
    {
        mode:'saveWork',
        'workData':JSON.stringify(workData)
    });

2、java代码:

    List<Map<String,String>> list = gson.fromJson(request.getParameter("workData"), new TypeToken<List<Map<String,String>>>(){}.getType());
    for(Map<String,String> map : list){
        System.out.print("pk:"+map.get("pk"));
        System.out.println("\tname"+map.get("name"));
    }

servlet解析post传递的json数组字符串

标签:json数组字符串   gson   

原文地址:http://blog.csdn.net/class_horse/article/details/46349219

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