Extjs 怎么获取hashmap?
通过javabean的方式可以获取,haspmap的时候不行.
extjs:
var typeStore = new Ext.data.Store({
autoLoad :true,
reader: new Ext.data.XmlReader({
totalRecords: "results",
record: "BookType", //haspmap的时候 怎么写? record: "map" 获取不了..
id: "id"
},
Ext.data.Record.create([
{name: 'id'},
{name: 'title'},
{name: 'detail'}
])
),
proxy : new Ext.data.HttpProxy({
url : 'test.do?method=getBookTypeList'
})
})
javabean方式:
BookType bookType = new BookType();
bookType.setId(001);
bookType.setTitle("散文集");
bookType.setDetail("鲁迅");
list.add(bookType);
解析的xml:
<?xml version="1.0" encoding="GBK"?>
<list>
<Total>
<results>1</results>
</Total>
<BookType>
<id>1</id>
<title>散文集</title>
<detail>鲁迅的书</detail>
</BookType>
</list>
现在要用haspmap方式
haspmap方式:
Map map=new HashMap();
map.put("id","001");
map.put("title","散文集");
map.put("detail","鲁迅");
list.add(map);
解析的xml:
<?xml version="1.0" encoding="GB
<list>
<Total>
<results>1</results>
</Total>
<map>
<entry>
<string>title</string>
<string>散文集</string>
</entry>
<entry>
<string>detail</string>
<string>鲁迅</string>
</entry>
<entry>
<string>id</string>
<string>001</string>
</entry>
</map>
</list>