JSF没有可以迭代的任何组件
Map。只有JSTL
<c:forEach>可以迭代
Map。每次迭代都会为您提供
Map.Entry支持,而该支持又具有
getKey()和
getValue()方法。您可以依次使用a
<h:dataTable>来迭代地图值。
<c:forEach items="#{bean.map}" var="entry"> <p>Key: <h:outputText value="#{entry.key}" /></p> <h:dataTable value="#{entry.value}" var="foo"> <h:column><h:outputText value="#{foo.prop1}" /></h:column> <h:column><h:outputText value="#{foo.prop2}" /></h:column> <h:column><h:outputText value="#{foo.prop3}" /></h:column> </h:dataTable></c:forEach>*仅当您使用JSTL 1.2时 *更新 此功能。这在JSTL 1.1中失败,因为
#{}在JSTL1.1标记中无法识别,因此您不得不使用
${},但是在嵌套的JSF组件中这又失败了,因为它们#{}仅接受。基本上,您需要在整个代码段中使用“普通”JSP / HTML,或者更好的是使用Tomahawk的<t:dataList>。



