大家好:
后台返回的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