日期:2014-05-20  浏览次数:20780 次

我树我树我树树树(struts2 ext2.0)
[code=Java][/code]这是ext2.0的代码 、
JScript code

   1. <script type="text/javascript">  
   2. Ext.onReady(function(){  
   3.     var Tree = Ext.tree;  
   4.       
   5.         var tree = new Ext.tree.TreePanel({  
   6.         el:'tree-div',  
   7.         autoScroll : true,  
   8.             animate : true,  
   9.            enableDD : true,  
  10.             containerScroll : true,  
  11.            loader : new Tree.TreeLoader({  
  12.                 dataUrl : 'initialize.action'  
  13.             })  
  14.     });  
  15.       
  16.     var root = new Ext.tree.AsyncTreeNode({  
  17.         text:'ASK123',  
  18.         draggable : false,  
  19.         id:'0000'  
  20.     });  
  21.       
  22.     tree.setRootNode(root);  
  23.       
  24.         tree.render();  
  25.   
  26.             root.expand();  
  27. });  
  28. </script>  



这个java代码
Java code

# public String execute() throws Exception {  
#     // ...  
#     list = moduleService.findBySjmkm(this.node);  
#     if(list != null && list.size() > 0){  
#         boolean isFirst = true;  
#            int last = list.size();  
#            int count = 0;  
#            for (int i = 0; i < list.size(); i++) {  
#             Module m = (Module) list.get(i);  
#              if (count == 0) {  
#                     this.setJsonString("[{\"text\" :\"" + m.getMc() + "\" ,\"id\" :\"" + m.getBh()  
#                                   + "\" ,\"cls\" :\"folder\"} ");  
#              } else if (i == (last - 1)) {  
#                     this.setJsonString(this.getJsonString() + ",{\"text\" :\"" + m.getMc() + "\" ,\"id\" :\""  
#                                   + m.getBh() + "\" ,\"cls\" :\"folder\"}]");  
#              } else {  
#                     this.setJsonString(this.getJsonString() + ",{\"text\" :\"" + m.getMc() + "\" ,\"id\" :\""  
#                                   + m.getBh() + "\" ,\"cls\" :\"folder\"}");  
#              }  
#             count++;  
#         }  
#            System.out.println(this.getJsonString());  
#     }  
#     return SUCCESS;  
# }  


java代码里json我打出来是这个格式
[{"text" :"ALA管理" ,"id" :"5500" ,"cls" :"folder"} ,{"text" :"行销管理" ,"id" :"6100" ,"cls" :"folder"},{"text" :"财务管理" ,"id" :"7000" ,"cls" :"folder"},{"text" :"案件管理" ,"id" :"9000" ,"cls" :"folder"},{"text" :"系统" ,"id" :"1100" ,"cls" :"folder"},{"text" :"电子商务平台" ,"id" :"1300" ,"cls" :"folder"},{"text" :"会员管理" ,"id" :"3100" ,"cls" :"folder"},{"text" :"决策分析" ,"id" :"8010" ,"cls" :"folder"},{"text" :"协同办公平台" ,"id" :"8510" ,"cls" :"folder"},{"text" :"公开班管理" ,"id" :"1501" ,"cls" :"folder"},{"text" :"加盟商合作接口" ,"id" :"668471" ,"cls" :"folder"}]
======================================
现在问题是前台树只出来一个根节点,得不到后台的数据,但是我吧数据源dataUrl : 'initialize.action'换成一个txt文本,文本里面写action得到的json却可以!到手帮小弟解决一下啊!!