开发者

How to use Java constantns as a parameter in a Struts 2 OGNL tag

开发者 https://www.devze.com 2023-01-21 09:51 出处:网络
I am ussingto recover a property from an object User in the session. The following expression works correctly:

I am ussing to recover a property from an object User in the session. The following expression works correctly:

<s:property value="#session.ATRB_SESSION_USER.getAttribute('ATTRIBUTE_USER_NAME')"/>

but those strings ATRB_SESSION_USER and ATTRIBUTE_USER_NAME are constatns defined in a class. How can I use the constant instead of the string? I'd like to do something like this

<s:property value="#session.<%=C开发者_运维知识库onstants.ATRB_SESSION_USER%>.getAttribute(<%=Constants.ATTRIBUTE_USER_NAME%>)"/>

Anyone knows how can I do that? TIA


You can use @class@field OGNL syntax to refer to static fields. The class name in @class should be fully qualified.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号