Get specific element in a list or array using EL

前端 未结 1 514
遇见更好的自我
遇见更好的自我 2020-11-27 17:27

Is it possible to get specific element in list or array using EL in a Java EE page (Facelets or JSP), or do I have to create a custom EL method?

相关标签:
1条回答
  • 2020-11-27 18:00

    You can use the brace notation [] wherein you specify the (zero-based) index of the element you'd like to retrieve.

    <p>This is the 3rd item of the list: #{bean.list[2]}</p>
    

    This syntax does basically the same as bean.getList().get(2).

    This is equivalent for arrays.

    <p>This is the 3rd item of the array: #{bean.array[2]}</p>
    

    This syntax does basically the same as bean.getArray()[2].

    See also:

    • Our EL wiki page
    0 讨论(0)
提交回复
热议问题