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却没有数据显示,求解???哪里出错了??