forEach嵌套循环的问题

时间:2024-04-26 00:05:15

程序中:

List firstList =
for(int i=; i<firstList.size(); i++) {
List secondListList =
request.setAttribute("option" + i, secondList);
}
request.setAttribute("first", firstList);

页面中:

<%int i=; %>
<c:forEach items="${first }" var="list">
${list.title }
<c:forEach items="${_____ }" var="olist">
<%i++; %>
${olist.optioni }</span>
</c:forEach>
</c:forEach>

请问我内层循环的items="${__________ }"该怎么填?

<%
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c"); List<String> member = new ArrayList<String>();
member.add("hello");
member.add("world"); request.setAttribute("list", list); for(int i = ; i < list.size(); i++) {
request.setAttribute("option" + i, member);
} %> <c:forEach items="${requestScope.list}" varStatus="status" var="item">
${item}的选项
<c:set value="${'option'}${status.index}" var="option" />
<c:forEach items="${requestScope[option]}" var="i">
${i}
</c:forEach> <br>
</c:forEach>