且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在没有< h:dataTable/>的情况下渲染2D数组

更新时间:2023-02-26 16:25:00

您可以使用ui:repeat代替c:forEach,我尝试了一个示例,它很适合我. c:foreach是一个标记处理程序,请查看@BalusC的以下帖子,以了解有关为什么不应该将标记处理程序用于视野范围的bean的更多信息.

You can use ui:repeat instead of c:forEach, I tried myself with a sample and it worked for me. c:foreach is a tag-handler and please take a look at the following post of @BalusC to learn more about why you should not use tag handlers with view-scoped beans.

JSF2 Facelets中的JSTL ...有意义吗?

<table>
<ui:repeat value="#{sampleBean.twodarray}" var="firstLevel" varStatus=#{vs}>
    <tr>
    <ui:repeat value="#{firstLevel}" var="secondLevel" rendered="#{!empty  firstLevel}">
        <td>#{vs.index} - #{secondLevel}</td>
    </ui:repeat>
    <h:panelGroup rendered="#{empty firstLevel}">
        <td colspan="3">empty</td>
    </h:panelGroup>
    </tr>
</ui:repeat>
</table>