问题描述
publicvoidgetTree(){List<Tmenu>list=permissionService.findTree();List<Tree>treeList=newArrayList<Tree>();List<Tree>treeListChildren=newArrayList<Tree>();List<Tree>treeListChildrenGrandson=newArrayList<Tree>();List<Tree>children4=newArrayList<Tree>();List<Object>listObject=newArrayList<Object>();for(Tmenut:list){Treetree=newTree();Tmenutm=t.getTmenu();//获得当前节点的父节点对象if(tm!=null){Stringstr=t.getId().substring(0,3);Strings=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);}elseif(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);
解决方案
解决方案二:
第二级以后的数据你拿到了吗