...">

Struts 2 if tag: constant test

I am linking to do the following code:

<s:if test="%{#beanVar == com.mycompany.project.NOT_REGISTERED} ">
 <td>NOT REGISTRED</td>
</s:if>

where com.mycompany.project.NOT_Rector is the static field of the class:

public static final long NOT_REGISTERED == 0;

I can not find in the Struts2 documentation a way to display a constant at runtime.

Thanks in advance for your help.

PS: I would not want to use the old school design <%%>

+3
source share
2 answers

From the basics of OGNL:

Access to Static Properties OGNL supports access to static properties as well as static methods.

By default, Struts 2 is configured to prohibit this - to enable OGNL static member support, you must set struts.ognl.allowStaticMethodAccess constant to true through any of the Permanent Configuration Methods.

OGNL :

@some.package.ClassName@FOO_PROPERTY
@some.package.ClassName@someMethod()

XWork "vs":

@vs@FOO_PROPERTY @vs@someMethod()
@vs1@FOO_PROPERTY @vs1@someMethod()
@vs2@BAR_PROPERTY @vs2@someOtherMethod()

"vs" "-". , , "vs", . "vs", .

,

+4
<s:if test="%{#beanVar == @com.mycompany.project@NOT_REGISTERED}">
  <td>NOT REGISTRED</td>
</s:if>

@ .

0

All Articles