将List集合构建为多级菜单
private List<MenuVO> getNode(List<MenuVO> list, String parentId) { List<MenuVO> nodes = list.stream().filter(w -> w.getParentId().equals(parentId)).collect(Collectors.toList()); for (MenuVO item : nodes) { item.setItemList(GetChildrens(list, item)); } return nodes; } private List<MenuVO> GetChildrens(List<MenuVO> list, MenuVO node) { List<MenuVO> childrens = list.stream().filter(w -> w.getParentId().equals(node.getId())).collect(Collectors.toList()); for (MenuVO item : childrens) { item.setItemList(GetChildrens(list, item)); } return childrens; }