Get specific element in a list or array using EL

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:

Leave a Comment