Struts 2 dynamic variables
It seems like a workaround but you can use attr
to evaluate string.
<s:set var="myNum" value="numConst" />
<s:set var="number" value="'@xxx.CommonConstant@'+#myNum" />
<s:property value="#attr[#number]"/>
<s:if test="#attr[#number] == 9">
do something
</s:if>
You can use parenthesesized expression to evaluate result of the expression.
<s:if test="#number(0) == 9">
<s:property value="%{#number(0)}" />
</s:if>
Look at the Expression Evaluation of the OGNL language guide.