且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态struts2对象字段名称

更新时间:2023-02-19 08:32:48

使用方括号从bean中获取值。

Use square brackets to get value from the bean.

<s:property value="#entity[#fieldMD.value.name]" />

这是可能的,因为内部OGNL将以下表达式视为完全相同。

It is possible because internally OGNL treats following expressions exactly the same.

所以

<s:property value="date.time" />

<s:property value="date['time']" />

产生相同的结果。