我无法创建列表,我需要列表
但是我的代码
之后 List<MainMenu> listmainmenu;
List<MergeSubMenuPojo> listmergesubmenu;
List<MergeSubSubMenuPojo> listmergesubsubmenu;
Map<Long, List<MergeSubMenuPojo>> submainmenumap = new HashMap<Long, List<MergeSubMenuPojo>>();
Map<Long, List<MergeSubSubMenuPojo>> ssmmmap = new HashMap<Long, List<MergeSubSubMenuPojo>>();
Map<Long, Map<Long,List<MergeSubSubMenuPojo>>> subsubmainmenumap = new HashMap<Long, Map<Long,List<MergeSubSubMenuPojo>>>();
Iterator<MainMenu> itmainmenu;
Iterator<MergeSubMenuPojo> itsubmainmenu;
listmainmenu = mainmenudao.findAll();
for (itmainmenu = listmainmenu.iterator(); itmainmenu.hasNext();) {
mainmenu = (MainMenu)itmainmenu.next();
listmergesubmenu = submainmenudao.findAllMerge(mainmenu.getId());
submainmenumap.put(mainmenu.getId(), listmergesubmenu);
for(itsubmainmenu = listmergesubmenu.iterator(); itsubmainmenu.hasNext();){
submainmenu = itsubmainmenu.next();
listmergesubsubmenu = subsubmainmenudao.findAllMerge(mainmenu.getId(),submainmenu.getId());
ssmmmap.put(submainmenu.getId(), listmergesubsubmenu);
subsubmainmenumap.put(mainmenu.getId(), ssmmmap);
modelAndView.addObject("listmainmenu",listmainmenu);
modelAndView.addObject("submainmenu",submainmenumap);
modelAndView.addObject("subsubmainmenu",subsubmainmenumap);
}
}
<c:forEach var="mm" items="${listmainmenu}">
<li><input type="hidden" value="${mm.id}" class="m">
<a href="#"><c:out value="${mm.menuname}"/></a>
<ul>
<c:forEach var="smm" items="${submainmenu[mm.id]}">
<li><input type="hidden" value="${smm.id}">
<a href="#">*<c:out value="${smm.submenuname}"/></a>
<ul>
<c:forEach var="ssmm" items="${subsubmainmenu[mm.id][smm.id]}">
<li><input type="hidden" value="${ssmm.id}">
<a href="#">**<c:out value="${ssmm.subsubmenuname}"/></a>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
答案 0 :(得分:0)
你正在为其他/或嵌套的forloops中的循环,所以你不需要像数组一样的情况,只需从当前的迭代变量中选择列表。在Shouting Code
上没有这样的情况<c:forEach var="mm" items="${not empty listmainmenu}">
<li><input type="hidden" value="${mm.id}" class="m">
<a href="#"><c:out value="${mm.menuname}"/></a>
<ul>
<c:forEach var="smm" items="${not empty mm.submainmenu}">
<li><input type="hidden" value="${smm.id}">
<a href="#">*<c:out value="${smm.submenuname}"/></a>
<ul>
<c:forEach var="ssmm" items="${not empty smm.subsubmainmenu}">
<li><input type="hidden" value="${ssmm.id}">
<a href="#">**<c:out value="${ssmm.subsubmenuname}"/></a>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
<c:forEach>