程序中:
List firstList = for(int i=0; i<firstList.size(); i++) { List secondListList = request.setAttribute("option" + i, secondList); } request.setAttribute("first", firstList);
页面中:
<%int i=0; %> <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 = 0; 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>
时间: 2024-10-25 22:30:11