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 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试