Struts 2 dynamic variables

前端 未结 2 1201
眼角桃花
眼角桃花 2020-11-30 13:59

I\'m trying to create a dynamic variable in Struts2 using set tag


&         


        
相关标签:
2条回答
  • 2020-11-30 14:20

    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.

    0 讨论(0)
  • 2020-11-30 14:32

    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>
    
    0 讨论(0)
提交回复
热议问题