Struts 2 dynamic variables

限于喜欢 提交于 2019-11-27 05:25:46

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!