Iterate through List using JSF 2

前端 未结 1 1554
忘掉有多难
忘掉有多难 2021-02-07 09:12

I have this java code.

List myList = new ArrayList();
myList.add(\"Hello\");
myList.add(\"World\");

I need to loop

相关标签:
1条回答
  • 2021-02-07 09:52

    You can use <ui:repeat>:

    <ui:repeat value="#{bean.myList}" var="value">
        #{value} <br />
    </ui:repeat>
    

    If you're not sure if you should use <h:dataTable> or <ui:repeat>, you can check an example that mkyong provides here: JSF 2 repeat tag example

    In short: <h:dataTable> renders a <table> HTML component, while <ui:repeat> gives you the flexibility to choose how to display the data.

    0 讨论(0)
提交回复
热议问题