1. 程式人生 > >$.post傳JSON到後臺及接收方法

$.post傳JSON到後臺及接收方法

前端://拼裝JSON格式資料json

             var json={"edit":[{"bh":"11111","mc":"11111","dbms":"ORACLE9i","dwmmc":"","addr":"","username":"","password":"","rm_sz":"ck","nyr_sz":"","id":"-1"},{"bh":"121","mc":"12","dbms":"ORACLE9i","dwmmc":"12","addr":"12","username":"12","password":"12","rm_sz":"ck","nyr_sz":"2011-09-06","id":"13"}],"del":["12"]};

             var post={data:JSON.stringify(json)};//JSON.stringify(json)把json轉化成字串
             $.post(url,post);

後臺:JSONObject json=JSONObject.fromObject(request.getParameter("data"));
             List<Map<String,String>> edit=(List<Map<String, String>>) json.getJSONArray("edit");
             List<?> del=(List<?>) json.getJSONArray("del");