lit*_*ahn 17 foreach jsp scope jstl jspinclude
我试图访问一些在包含JSTL for循环中设置的JSTL变量.
例:
<c:forEach items="${cart.entries}" var="entry">
 <jsp:include page="helper.jsp"></jsp:include>
</c:forEach>
在helper.jsp里面我希望能够引用变量'entry'.它一直是'空'.我想也许可能有一种方法可以将范围添加到forEach变量,就像使用普通的设置变量一样.
有任何想法吗?
lit*_*ahn 28
答案:我最终不得不这样做才能让它发挥作用.
<c:forEach items="${cart.entries}" var="entry">
<c:set var="entryFC" value="${entry}" scope="request"></c:set>
 <jsp:include page="helper.jsp"></jsp:include>
</c:forEach>
然后我在我的include中引用了entryFC.不是很优雅,但它的工作,所以我想生病了.
| 归档时间: | 
 | 
| 查看次数: | 10538 次 | 
| 最近记录: |