递归下拉列表树
public String add() throws Exception { Property property = new Property(); property.setDeleteFlag('0'); propertyList = this.getFacadeFactory().getGdsPropertyFacade().findByExample(property); Category cate = new Category(); cate.setDeleteFlag('0'); List list1 = new ArrayList(); List list = this.getFacadeFactory().getGdsCategoryFacade().findByExample(cate); dtoList = getNewList(new Long(0),list,list1,0); return SUCCESS; } /** *categoryList 为原先未排序的列表 *list1 排序完后的列表 * i 为递归的次数 */ private List getNewList(Long id, List categoryList,List list1,int i) throws Exception { i++; for(Category category :categoryList) { if(category.getParentId().equals(id)) { CategoryDto categoryDto = new CategoryDto(); categoryDto.setId(category.getCateId()); categoryDto.setParentId(category.getParentId()); StringBuilder sb = new StringBuilder(); for(int j=0;j