xiaoyaolang5254238
2009-05-21 14:59
浏览 209
已采纳

struts1.2页面通过ext获取json数据问题,为什么没有数据?

这是我的代码,望各位大哥大姐们 看看,帮我找找问题,谢谢了!
我 url: 'login.do?method=alluser',这句代码没有执行,因为后台没有打印,
页面的ext代码:
Ext.onReady(function(){

Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); 
// example of custom renderer function 
   var store = new Ext.data.JsonStore({ 
          autoload:true,
          proxy: new Ext.data.HttpProxy({ 
          url: 'login.do?method=alluser', 
          method:'post', 
          reader: new Ext.data.JsonReader({   
             totalProperty:'pageInfo',    
            root:'data', 
             fields:[        {name: 'userid',mapping:'data.userid'}, 
                             {name: 'groupid',mapping:'data.groupid'}, 
                             {name: 'username',mapping:'data.username'}, 
                             {name: 'pwd', mapping:'data.pwd'}, 
                             {name: 'store',mapping: 'data.store'}, 
                             {name: 'rfset', mapping: 'data.rfset'} 
] 

})
})
});

// create the Grid 
var grid = new Ext.grid.GridPanel({ 
    store: store, 
    columns: [ 
        {id:'userid',header: "userid", width: 60, sortable: true, dataIndex: 'userid'}, 
        {header: "groupid", width: 60, sortable: true,  dataIndex: 'groupid'}, 
        {header: "username", width:60, sortable: true,  dataIndex: 'username'}, 
        {header: "pwd", width:60, sortable: true, dataIndex: 'pwd'}, 
        {header: "store", width: 60, sortable: true, dataIndex: 'store'}, 
        {header: "rfset", width: 60, sortable: true, dataIndex: 'rfset'} 
    ], 
    autoWidth:false, 
    width:780, 
    autoHeight:true, 
    bbar: new Ext.PagingToolbar({        
       pageSize: 25,        
       store: store,        
       displayInfo: true,        
       displayMsg: ' 本页显示从{0} 到 {1} 条,共 {2} 条数据',        
       emptyMsg: "没有可以显示的数据"        
   })    

}); 

grid.render('grid-example'); 

grid.getSelectionModel().selectFirstRow(); 

});

JavaAction代码:
public ActionForward alluser(ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) throws IOException{
ILoginservice inter=(Loginservice)this.getBean("loginDao");
List users=inter.findAll(Userinfo.class);
System.out.print("=====================================");
JSONArray arr=new JSONArray();
String tabstring="";
for(Object o : users){
Userinfo u=(Userinfo)o;
arr.add(u);
}
try {
JSONObject object=new JSONObject();
object.put("data", arr);
object.put("pageInfo",users.size());

tabstring = object.toString();
} catch (Exception e) {
tabstring = "ss";
}
System.out.println("++++++++++++++++"+tabstring);
res.getWriter().write(tabstring);
return mapping.findForward("userlist");
}

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题