使用 EL 获取列表或数组中的特定元素 [英] Get specific element in a list or array using EL
本文介绍了使用 EL 获取列表或数组中的特定元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 Java EE 页面(Facelets 或 JSP)中使用 EL 获取列表或数组中的特定元素,或者我是否必须创建自定义 EL 方法?
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?
推荐答案
您可以使用大括号表示法 []
在其中指定您想要的元素的(从零开始的)索引取回.
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>
此语法与bean.getList().get(2)
基本相同.
这对数组来说是等价的.
This is equivalent for arrays.
<p>This is the 3rd item of the array: #{bean.array[2]}</p>
此语法与bean.getArray()[2]
基本相同.
这篇关于使用 EL 获取列表或数组中的特定元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文