在jsp中<c:foreach>做2个list循环 怎么让他不重复循环 用的是ssm框架 5
controller层的方法publicStringgetSchoolGradeClass(){List<Map>list=schoolGradeClassService...
controller层的方法
public String getSchoolGradeClass(){
List<Map> list = schoolGradeClassService.getSchoolGradeClassList();
getRequest().setAttribute("schoolGradeClass", list);
return "/jsps/basis/basicInformation/GCmaintenance/maintenance";
}
jsp页面的三重forEach循环
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass1">
<li>
<span>${schoolGradeClass1.school_name}</span>
<ul>
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass2">
<li>
<span onclick="window.main.location.href='<%=request.getContextPath()%>/jsps/basis/basicInformation/GCmaintenance/maintenance2.jsp'">${schoolGradeClass2.grade_name}</span>
<ul>
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass3">
<li>
<span onclick="window.main.location.href='<%=request.getContextPath()%>/jsps/basis/basicInformation/GCmaintenance/maintenance3.jsp'">${schoolGradeClass3.class_name}</span>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
因为是三个表的连接查询所以弄了3重forEach 展开
public String getSchoolGradeClass(){
List<Map> list = schoolGradeClassService.getSchoolGradeClassList();
getRequest().setAttribute("schoolGradeClass", list);
return "/jsps/basis/basicInformation/GCmaintenance/maintenance";
}
jsp页面的三重forEach循环
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass1">
<li>
<span>${schoolGradeClass1.school_name}</span>
<ul>
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass2">
<li>
<span onclick="window.main.location.href='<%=request.getContextPath()%>/jsps/basis/basicInformation/GCmaintenance/maintenance2.jsp'">${schoolGradeClass2.grade_name}</span>
<ul>
<c:forEach items="${schoolGradeClass}" var = "schoolGradeClass3">
<li>
<span onclick="window.main.location.href='<%=request.getContextPath()%>/jsps/basis/basicInformation/GCmaintenance/maintenance3.jsp'">${schoolGradeClass3.class_name}</span>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
</ul>
</li>
</c:forEach>
因为是三个表的连接查询所以弄了3重forEach 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询