<%int i=0;%>
<c:set var=i >
<c:forEach items="${resVOlist}" var="it" varStatus="s">
<c:if test="${it.parent==null}">
<c:out  value="<%=i%>" />
<%i++;%>
<c:if test="${i== 0 || i%2 == 0}">

请问倒数第二行i++后,最后那个if里面怎么取到这个++后的i的值呢???这么取反正取不到,求大神指导指导。跪谢!!!!!!JSP JSTL if  

解决方案 »

  1.   

    为啥不用 index 和 count,你自己还定义一参数每次自己加
      

  2.   

    直接用 s.index 好了 <%i++;%>
    //打印看看
     <c:out  value="<%=i%>" />
          <c:if test="${i== 0 || i%2 == 0}">
      

  3.   

    你这怎么取也取不到的, C标签的迭代和小脚本的代码块是没办法融入在一起, 除非你是用小脚本request,或或者session里面先放入缓存,然后用标签取,  其实你可以把要i++的话  其实你现在刚刚的上面的代码  可以改为
                    <c:set var=i >
                <c:forEach items="${resVOlist}" var="it" varStatus="s">
                    <c:if test="${it.parent==null}">
                   <c:if test="${s.index== 0 || s.index%2 == 0}">  就可以了