日期:2014-05-18  浏览次数:20665 次

JSTL中的一个关于循环的问题
我想用JSTL循环特定次数,这个次数是变量,不知道该怎么做啊?我用下面的做法,提示有错!
-------------------------------------------------
(37)转到第   <SELECT   name= "page "   onchange= "jumping() ">
(38) <c:forEach   var= "i "   begin= "1 "   end= "${pageData.totlePages} ">
(39) <c:choose>
(40) <c:when     test= "${i==pageData.curPage} ">
(41) <OPTION   selected   value= " <c:out   value= "${i} "/> "   > <c:out   value= "${i} "/> </OPTION>
(42) </c:when>
(43) <c:otherwise>
(44) <OPTION   value= " <c:out   value= "${i} "   /> "   > <c:out   value= "${i} "   /> </OPTION>
(45) </c:otherwise>
(46) </c:choose>
(47) </c:forEach>
(48) </SELECT>   页
-------------------------------------------
e.toString():
org.apache.jasper.JasperException:   Exception   in   JSP:   /admin/pageBar.inc:38   35:   36:   37:   转到第     38:     39:     40:     41:   "   >   Stacktrace:   e.getMessage():Exception   in   JSP:   /admin/pageBar.inc:38   35:   36:   37:   转到第   38:   39:   40:   41:   "   >   Stacktrace:


------解决方案--------------------
转到第 <SELECT name= "page " onchange= "jumping() ">
<c:forEach var= "i " begin= "1 " end= "${pageData.totlePages} ">
<c:choose>
<c:when test= "${i==pageData.curPage} ">
<OPTION selected value= "${i} "> ${i} </OPTION>
</c:when>
<c:otherwise>
<OPTION value= "${i} "> ${i} </OPTION>
</c:otherwise>
</c:choose>
</c:forEach>
</SELECT> 页


试试看呗
------解决方案--------------------
c:forEach的item属性,为什么省掉?