struts2 后台: public void GetAllAccount(){
List<AccountBean> accountList = SqlMapClientInstanceUtil.getServiceInstance().queryForList("select_all_account");
JSONArray jsonMembers = new JSONArray();
for(AccountBean ab : accountList){
JSONObject jsonObj = new JSONObject();
jsonObj.put("aid", ab.getAcc_id());
jsonObj.put("aname", ab.getAcc_name());
jsonObj.put("apwd", ab.getAcc_pwd());
jsonObj.put("atype", ab.getAcc_type() == 0 ? "管理员" : "普通用户");
jsonMembers.add(jsonObj);
break;//测试
}
JSONObject jsonObj = new JSONObject();
jsonObj.put("total", 200);
jsonObj.put("rows", jsonMembers);
SetJSONResponse(jsonObj);
}
private void SetJSONResponse(JSONObject outPutMes) {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
PrintWriter out = response.getWriter();
out.print(outPutMes);
} catch (IOException e) {
e.printStackTrace();
}
}前台: $(function(){
initDg();
});
function initDg(){
$("#acctable").datagrid({
idField:'aid',
singleSelect: true,
width: 400,
url: "bbs/allaccount.action",
columns:[[
{field:"aid",title:'账号',width:80},
{field:"aname",title:'姓名',width:80},
{field:"apwd",title:'密码',width:80},
{field:"atype",title:'类型',width:80}
]]
});
}
用firefox查看,得到的JSON数据为:
{"total":200,"rows":[{"aid":"","aname":"","apwd":"","atype":"普通用户"}]}但是datagrid却没有数据显示,求解???哪里出错了??
List<AccountBean> accountList = SqlMapClientInstanceUtil.getServiceInstance().queryForList("select_all_account");
JSONArray jsonMembers = new JSONArray();
for(AccountBean ab : accountList){
JSONObject jsonObj = new JSONObject();
jsonObj.put("aid", ab.getAcc_id());
jsonObj.put("aname", ab.getAcc_name());
jsonObj.put("apwd", ab.getAcc_pwd());
jsonObj.put("atype", ab.getAcc_type() == 0 ? "管理员" : "普通用户");
jsonMembers.add(jsonObj);
break;//测试
}
JSONObject jsonObj = new JSONObject();
jsonObj.put("total", 200);
jsonObj.put("rows", jsonMembers);
SetJSONResponse(jsonObj);
}
private void SetJSONResponse(JSONObject outPutMes) {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
PrintWriter out = response.getWriter();
out.print(outPutMes);
} catch (IOException e) {
e.printStackTrace();
}
}前台: $(function(){
initDg();
});
function initDg(){
$("#acctable").datagrid({
idField:'aid',
singleSelect: true,
width: 400,
url: "bbs/allaccount.action",
columns:[[
{field:"aid",title:'账号',width:80},
{field:"aname",title:'姓名',width:80},
{field:"apwd",title:'密码',width:80},
{field:"atype",title:'类型',width:80}
]]
});
}
用firefox查看,得到的JSON数据为:
{"total":200,"rows":[{"aid":"","aname":"","apwd":"","atype":"普通用户"}]}但是datagrid却没有数据显示,求解???哪里出错了??
解决方案 »
- 高手请进。。。。synchronized的使用迷惑。
- hibernate树的持久化
- 面试提问解答,求帮助
- Cannot reset buffer after response has been committed
- 导出java虚拟机堆栈,总出现java.lang.Thread.State: WAITING?
- 请问java环境哪里下载呀
- 谁能给出一个代码片段,演示hibernate中的update,delete?
- weblogic6.1配置连接池的奇怪问题!
- 如何把ResultSet这个查询出来的table 结果转换成一个 与之对应的form
- 有没有大神,帮忙看一下我的程序啊
- strut2 spring idatis整合实现用户登录并实现增删改查功能及分页查询
- spring security出现An AuthenticationManager is required异常
{"total":200,"rows":[{"aid":"asda","aname":"asdasd","apwd":"asdasd","atype":"管理员"}]}
但仍然没有数据显示,真纠结啊,求解!!!!!!