json 怎么把数据库中数据读取出来 在怎么把它显示到页面
求例子
例如下面的样式
String articletype = java.net.URLDecoder.decode(request.getParameter("articletype"), "UTF-8");
JSONArray signs = new JSONArray();
JSONObject sign = new JSONObject();
// sign.get()
sign.put("dbid", "1");
sign.put("dbip", "2");
sign.put("dbport", "3");
sign.put("dbuser", "4");
sign.put("dbpws", "5");
sign.put("dbdriver", "6");
sign.put("dblinkurl", "7");
sign.put("dbname", "8");
sign.put("isok", "9");
sign.put("stoptime", "10");
sign.put("managerid", "11");
signs.put(sign);
returnstr = "{returnstr:'0',returndata:" + signs + "}";//返回信息
}
out.println(returnstr);
out.println(sdf);
------解决方案--------------------------------------------------------
在前端:var json = eval('('+response.responseText + ')');
json[0].dbid;
json[0].dbip;像这样你去遍历,前面使用eval()是当你在前端设置返回的是text而不是json类型时用的,如果解析不了的话,你再把eval()去掉