目录实体
private int id; private int pid; private String name;
递归遍历方法
private void getTree(Menu menu ,List<Menu> menus){ int pid = menu.getId(); List<Menu> childs = null; Iterator<Menu> iterator = menus.iterator(); while (iterator.hasNext()) { Menu m = iterator.next(); if(m.getPid() == pid){ childs = menu.getChild(); if(childs == null) childs = new ArrayList<Menu>(); childs.add(m); iterator.remove(); menu.setChild(childs); } } if(childs != null && !childs.isEmpty() && menus !=null && !menus.isEmpty()){ Iterator<Menu> iterator2 = childs.iterator(); while(iterator2.hasNext()){ Menu next = iterator2.next(); getTree(next,menus); } } }
----------------------------------------------------------------------------------------邪恶的分隔线-------------------------------------------------------------------------------------------------
这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数这是凑字数