您需要像这样填充模型:
public class Category{ private Integer id; private String name; private Category parentCategory; private List<Category> subCategories; ... //getters and setters}在Servlet中,您需要具有类别LEVEL 1的LIST(Parent为NULL)。
List<Category> rootCategories = getAllCategoriesLevel1();request.setAttribute("rootCategories", rootCategories );在JSP中(需要3个循环或4,5个循环)
<c:forEach items="${rootCategories}" var="categoryLevel1"> // ... <c:forEach items="${categoryLevel1.subCategories}" var="categoryLevel2"> // ... <c:forEach items="${categoryLevel2.subCategories}" var="categoryLevel3"> // ... </c:forEach> // ... </c:forEach> // ...</c:forEach>


