weixin_42373964 2010-06-09 11:37
浏览 212
已采纳

struts2 Action返回的json对象无法绑定到Ext grid中

大家好:

后台返回的json对象格式上好像出了点问题,参考成功的例子,json对象应该是以下格式:
{
total: 2,
root : [
{ id: 1, firstname: 'Bill', occupation: 'Gardener' }, // a row object
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' } // another row object
]
}

可是我现在的json对象只有root 里面这部分,如下:
{
{ id: 1, firstname: 'Bill', occupation: 'Gardener' }, // a row object
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' } // another row object
}

我从Ext的js文件,struts2的xml文件,后台action,都看了一遍也不知道是什么造成的?
Ext相关部分:
[code="javaScript"]
ds: new Ext.data.Store({
url : 'getCustomersList.action',
reader : new Ext.data.JsonReader({totalProperty : "total", root : "root"},
[{name : "customerCode", type : "string"},
{name : "customerName", type : "string"},
{name : "conDist", type : "boolean"},
{name : "supDist", type : "boolean"},
{name : "delDist", type : "boolean"},
{name : "consigneeDist", type : "boolean"},
{name : "dcCompDist", type : "boolean"},
{name : "shippingCompDist", type : "boolean"},
{name : "customerRank", type : "string"},
{name : "creditRank", type : "string"},
{name : "availDist", type : "boolean"}])
})
[/code]
struts2 xml相关部分
[code="xml"]



customersInfoList
true



[/code]

我的lib是:struts2-json-plugin-2.1.8.1.jar和json-lib-2.1.jar

  • 写回答

9条回答 默认 最新

  • upup1000 2010-06-09 13:03
    关注

    在后台写成root:[]或前台reader里边root:""

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(8条)

报告相同问题?

悬赏问题

  • ¥15 代码的修改,添加和运行完善
  • ¥15 krpano-场景分组和自定义地图分组
  • ¥15 lammps Gpu加速出错
  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题