java - JSTL foreach - how to loop from last to first -


this question has answer here:

<c:set var="eventslastindex" value="${events.size() - 1}" /> <c:foreach items="${events}" var="event"         begin="${eventslastindex}" end="0" step="-1">     ... </c:foreach> 

this code throws exception: javax.servlet.jsp.jsptagexception: 'step' <= 0

but, how iterate last element?

as specified in this question;

you can use sthg this;

<c:foreach var="i" begin="0" end="10" step="1" varstatus="loop">     ... ${loop.end - + loop.begin} ... </c:foreach> 

you must write foreach usual, , while getting value must decremental.


Comments

Popular posts from this blog

java - Unable to make sub reports with Jasper -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -

Passing Variables from AngelScript to C++ -