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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -