日期:2014-05-17 浏览次数:20691 次
public String execute()
{
List<Room> roomlist=roomService.findAllRoom();
ServletActionContext.getRequest().setAttribute("roomlist", roomlist);
System.out.println("查找完毕");
this.setTotalCount(roomlist.size());
JSONArray array=JSONArray.fromObject(roomlist);
this.jsonString="{totalCount:"+this.getTotalCount()+",results:"+array.toString()+"}";
/*return SUCCESS;*/
System.out.println("转换完毕");
return SUCCESS;
<action name="listRoom" class="ListRoom">
<result name="success" type="json"/>
<param name="jsonString">/ext_form.jsp</param>
</action>
Ext.onReady(function(){
Ext.define('Room',
{
extend:'Ext.data.Model',
fields:[{
name:'roomid',type:'int'
},
{
name:'roomname',type:'string'
},
{
name:'price',type:'int'
},
{
name:'category',type:'string'
},
{name:'status',type:'int'}]
});
var rd = new Ext.data.JsonReader({
//总记录数
totalProperty: 'totalCount',
//哪儿是数据的头,可以看action里面是怎么定义数据格式的,这里就是如何解析的
root: 'results',
id:'roomid',
//有那些字段呢?
fields:[
/* {name:'roomid'},
{name:'roomname'},
{name:'price'},
{name:'category'},
{name:'status'},*/
&nb