easyui tree我用java写的json,为什么我的第一级树出来了,然后其他的树都放到了第一级下的子级其他子级下面都是空的,求大侠帮忙
public void getTree(){List<Tmenu> list = permissionService.findTree();
List<Tree> treeList = new ArrayList<Tree>();
List<Tree> treeListChildren = new ArrayList<Tree>();
List<Tree> treeListChildrenGrandson = new ArrayList<Tree>();
List<Tree> children4 = new ArrayList<Tree>();
List<Object> listObject = new ArrayList<Object>();
for(Tmenu t : list){
Tree tree = new Tree();
Tmenu tm = t.getTmenu();// 获得当前节点的父节点对象
if(tm != null){
String str = t.getId().substring(0, 3);
String s = null;
//s = t.getId().substring(0, 5);
if(str.equals(tm.getId())){
// System.out.println(str+"*1111");
// System.out.println(tm.getId()+"*2222");
System.out.println("%%3级%%"+t.getText());
tree.setId(t.getId());
tree.setText(t.getText());
tree.setPid(tm.getId());
treeListChildren.add(tree);
//tree.setChildren(children4);
}else if(t.getId().length()>5 && t.getId().substring(0, 5).equals(tm.getId())){
System.out.println("@@4级@@"+t.getText());
tree.setId(t.getId());
tree.setText(t.getText());
tree.setPid(tm.getId());
tree.setChildren(children4);
// children4.add(tree);
treeListChildrenGrandson.add(tree);
}else{
tree.setId(t.getId());
tree.setText(t.getText());
System.out.println("**2级**"+t.getText());
tree.setPid(tm.getId());
tree.setChildren(treeListChildrenGrandson);
//treeListChildren.add(tree);
treeListChildren.add(tree);
}
//ma.put("children", treeListChildren);
}else{
tree.setId(t.getId());
tree.setText(t.getText());
System.out.println("##1级##"+t.getText());
tree.setChildren(treeListChildren);
treeList.add(tree);
}
}
super.writeJson(treeList); --------------------编程问答-------------------- 第二级以后的数据你拿到了吗
补充:Java , Web 开发