我是在action里面添加属性来自动传输json的
[code="java"]private Integer len;
private String root;
public String findAllStu() throws ParseException, IOException {
List stus = studentService.getAllStu();
len = stus.size();
root = JsonUtil.listToJson(stus, "student_list");
return "list";
}[/code]
struts.xml中:
[code="java"]
method="{1}">
[/code]
前台接收数据:
{"len":1,"root":"[{'studentId':'180','studentName':'张三','classInfo.classId':'140','studentNo':'JM123456','sex':'0','birthday':'2014-05-01','address':'','tel':'','email':'','mobilephone':'','userInfo.userId':'1'}]"}
js中的接收store:
[code="java"]var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:"studentAction^findAllStu"}),
reader: new Ext.data.JsonReader({
totalProperty: 'len',
root: 'root'
}, [
{name: 'studentName'}
])
});[/code]
觉得是数据的格式不对,就是store中的root应该是一个数组类型的,而我传过去的是一个字符串,这个怎么解决?