日期:2014-05-17  浏览次数:20670 次

Extjs无法接收显示Struts后台数据
如题
后台使用的是SSH框架,前台想用Ext呈现后台数据,数据已经能正常获取,但是没有显示出来,不知道是哪里配错了,按着网上
http://www.blogjava.net/fuhoujun/archive/2008/10/02/232050.html       的步骤做的  JSP页面能显示数据如图

下面是代码
Struts逻辑代码:

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;


Struts.xml

<action name="listRoom" class="ListRoom">
         <result name="success"  type="json"/>
 <param name="jsonString">/ext_form.jsp</param> 
            
       </action>



JS代码:



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