[英]Passing jstl's foreach varStatus into javascript
這可能嗎?
<c:forEach var="list" items="${requestScope.data}" varStatus="count">
<script>
myFunction(false,[]) // this is where i want to pass the `varStatus` on 2nd argument
</script>
</c:forEach>
我試過像這樣:
myFunction(false,${count.index});
myFunction(false,<c:out value="${count.index}"></c:out>);
這些都不起作用。 任何幫助,將不勝感激。 謝謝!
請嘗試這些測試。 他們都為我工作。 但是,使用名稱“ count for varStatus會造成混淆”。“ count”是LoopTagStatus接口中當前基於1的迭代計數的名稱。
<c:forEach var="list" items="a,b,c" varStatus="count">
myFunction(false,${count.index}) <br/>
</c:forEach>
<c:forEach var="list" items="a,b,c" varStatus="status">
myFunction(false,${status.index}) <br/>
</c:forEach>
<c:forEach var="list" items="a,b,c" varStatus="status">
my Function(false,${status.count}) <br/>
</c:forEach>
<c:forEach var="list" items="a,b,c" varStatus="count">
my Function(false,${count.count}) <br/>
</c:forEach>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.