[英]JSTL Iterate over 2 datasets?
This might be a easy one. 这可能很容易。 I currently have 1 dataset in a forEach and would like to iterate over a second one at the same time?
我目前在forEach中有1个数据集,想同时遍历第二个吗? Is this possible?
这可能吗?
<c:set value="${dataList}" var="beans" />
<c:set value="${newDataList}" var="newBeans"/>
<c:forEach var="bean" items="${beans}" varStatus="loopCount">
If the collections are always equal in size, you can loop through one and access the second based on index. 如果集合的大小始终相等,则可以遍历一个集合并根据索引访问第二个集合。
<c:forEach var="bean" items="${beans}" varStatus="loopCount">
<c:out value="${bean}" /> <c:out value="${newBeans[loopCount.index]}" />
</c:forEach>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.