java - JSTL c:forEach, decremental number loop impossible? -


i want print decremental numbers like:

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

then got jsp exception:

javax.servlet.jsp.jsptagexception: 'step' <= 0     javax.servlet.jsp.jstl.core.looptagsupport.validatestep(looptagsupport.java:459)     org.apache.taglibs.standard.tag.rt.core.foreachtag.setstep(foreachtag.java:60)     .... 

but answer says possible loop in both ways:

jstl foreach reverse order

what's wrong me?

i not sure how answerer of other question got work, can't work here reference jstl implementation.

anyway, can achieve requirement following:

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

or if you'd avoid duplication of 10:

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

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -