Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP mod operator not working

Tags:

jsp

jstl

I am trying this but its going to else part always

 <c:forEach items="${records}" var="field" varStatus="counter">

    <c:choose>
        <c:when test="${counter.count mod 2 == 0}">
            <div class="classEven">
        </c:when>
        <c:otherwise>
            <div class="classOdd">
        </c:otherwise>
    </c:choose>
        sample text here

        </div>          

 </c:forEach>

What's wrong with this?

like image 337
Harry Avatar asked Feb 03 '12 11:02

Harry


1 Answers

You could also use ${counter.count % 2 == 0}

like image 196
Max Peterson Avatar answered Sep 28 '22 09:09

Max Peterson