Extjs 怎么获取hashmap?

sideking 2010-03-09 11:35:22
通过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>
...全文
171 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sideking 2010-03-09
  • 打赏
  • 举报
回复
引用 1 楼 asdujiayong 的回复:
map.entrySet()


写在extjs的哪里呢?
asdujiayong 2010-03-09
  • 打赏
  • 举报
回复
map.entrySet()
asdujiayong 2010-03-09
  • 打赏
  • 举报
回复
在后台取到数据 不往list里加,
map.entrySet()以key :“--” value : "---"的形式返回

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧