【发布时间】:2016-10-25 08:29:19
【问题描述】:
我在 javascript 中有一个 arraList。我想让该 arrayList 在 html <c:forEach> 中进行迭代。我该怎么做。我可以将此 arrayList 获取到 <h:outputText> 但我想迭代列表。
我的javascriptarraList 是这样的
<script>
topCategory = new Array();
topCategory.push("one");
topCategory.push("two");
topCategory.push("threee");
topCategory.push("four");
</script>
我需要在 html <c:forEach> 中迭代这个 topCategory
例如:
<script>
topCategory = new Array();
topCategory.push("one");
topCategory.push("two");
topCategory.push("threee");
topCategory.push("four");
那么这个列表应该在一个
中迭代<table width="100%">
<tr>
<td rowspan="2" width="20%">
<c:forEach items="#{topCategory}" var="cat">
<p:commandButton value="#{cat}"/>
</c:forEach>
</td>
</tr>
【问题讨论】:
-
这和java有什么关系?
-
如果你想要
<c:forEach>,写一个。 -
@Jaiprakash
<c:forEach>来自JSP标准标签库,用于迭代Java数组、集合等 -
@Andreas 要编写
<c:forEach>,我需要将该arrayList 传递给html。我想知道该怎么做。我不想在javascript 中添加<c:forEach>。我需要传递 topCategory arrayList ïnsidehtml像` -
@chinthi 可能你可以使用 knockoutjs 在 html 中进行迭代
标签: javascript java arraylist