Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

for loop to jstl forEach

Tags:

java

jstl

How to convert below for loop to a jstl foreach:

for(int i = 0 ; i<=21; i+=3){
  // print foo
}

This is what I have so far:

<c:forEach varStatus="loop" begin="0" end="21">
  // display foo
</c:forEach>
like image 779
tokhi Avatar asked Nov 05 '13 11:11

tokhi


1 Answers

Acoording to jstl you should try:

<c:forEach begin="0" end="21" step="3" varStatus="loop">
    <c:out value="${loop.count}"/>
</c:forEach>
like image 137
user987339 Avatar answered Oct 11 '22 05:10

user987339