var jsonMsg = new Object(); jsonMsg.msg = msg; jsonMsg.info = info; var json = JSON.stringify(jsonMsg); 生成 json : {"msg":"-100","info":"xxxxxxx"} Ajax: $.ajax({ type: 'POST', url: getRootPath()+"/log/gis/testExc.do", data: {"jsonStr":json}, dataType: 'json', success: function(data) { alert("succes"); }, error: function(XMLHttpRequest, textStatus, errorThrown) { } }); Java: JSONObject json = JSONObject.fromObject(request.getParameter("jsonStr")); String msg = StringUtils.trimToNull(json.getString("msg")); String info = StringUtils.trimToNull(json.getString("info")); System.out.println("进入Action"+msg+"\t"+info); jQuery.parseJSON: var objs = jQuery.parseJSON('{"msg":' + '"'+msg+'"' + ',"info":' + '"'+info +'"'+ '}');
Jquery 生成 Json 字符串
猜你喜欢
转载自xinjiatao.iteye.com/blog/2205172
今日推荐
周排行