服务器端jsonservlet中代码:
List<Map<String,String>> jsonlist=new ArrayList<Map<String,String>>();
Map<String,String> tempmap=new IdentityHashMap<String,String>();
tempmap.put("name","tomcat");
tempmap.put("value", "1234567");
jsonlist.add(tempmap);
tempmap=null;
JSONArray jsonarray=null;
jsonarray=new JSONArray(jsonlist);
System.out.println(jsonarray);//输出结果为[{"name":"tomcat","value":"1234567"}]
out.flush();
out.close();前台JSP页面中的js脚本处理json数据如下:
$.getJSON("jsonservlet",{ "resultType": "json" },function(datas) {
alert(datas); //输出结果为null!!!!!!
})请jquery高手指点!
List<Map<String,String>> jsonlist=new ArrayList<Map<String,String>>();
Map<String,String> tempmap=new IdentityHashMap<String,String>();
tempmap.put("name","tomcat");
tempmap.put("value", "1234567");
jsonlist.add(tempmap);
tempmap=null;
JSONArray jsonarray=null;
jsonarray=new JSONArray(jsonlist);
System.out.println(jsonarray);//输出结果为[{"name":"tomcat","value":"1234567"}]
out.flush();
out.close();前台JSP页面中的js脚本处理json数据如下:
$.getJSON("jsonservlet",{ "resultType": "json" },function(datas) {
alert(datas); //输出结果为null!!!!!!
})请jquery高手指点!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货