使用EL动态访问Bean属性 [英] Accessing a Bean Property Dynamically using EL
本文介绍了使用EL动态访问Bean属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在JSP页面中使用EL访问其名称存储在变量中的bean的属性。
I need to access a property of a bean whose name is stored in a variable using EL in a JSP page.
如果我要访问名为描述,然后我会去$ {bean.description},但由于属性的名称存储在变量name中,我不知道如何在EL中执行此操作。
If I were to access a property named "description", then I would go ${bean.description}, but since the name of the property is stored in the variable "name", I have no idea how I would do it in EL.
这可能吗?如果没有,有没有人有解决方法?
Is this possible? If not, does anyone have a workaround?
非常感谢。
推荐答案
使用表格 $ {bean [name]}
。更多解释可在§ Java ServerPages 2.0规范的JSP.2.3.4。
Use the form ${bean[name]}
. More explanation is available in § JSP.2.3.4 of the Java ServerPages 2.0 Specification.
这篇关于使用EL动态访问Bean属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文