【发布时间】:2016-04-04 20:10:23
【问题描述】:
我正在尝试重构我的代码,并且正在寻找一种可能性来动态设置 <s:textfield> 的关键属性。
所以我的代码如下所示:
<s:set name="type" value="%{process.commands[%{#counter}].type}"/>
<s:if test="%{#type.getLabel() == 'Start'}">
<s:textfield name="process.commands[%{#counter}].statement"
key="lbl.commandType.start"/>
</s:if>
<s:if test="%{#type.getLabel() == 'Stop'}">
<s:textfield name="process.commands[%{#counter}].statement"
key="lbl.commandType.stop"/>
</s:if>
<s:if test="%{#type.getLabel() == 'Check'}">
<s:textfield name="process.commands[%{#counter}].statement"
key="lbl.commandType.check"/>
</s:if>
但我真正寻找的是这样的东西,所以它会在一行中:
key="lbl.commandType.'%{#type.getLabel()}'"
或
key="lbl.commandType.<s:property value='#type.getLabel()'/>"/>
但是这些都不起作用,我没有找到任何关于动态键属性的信息。有谁知道解决方案?
【问题讨论】:
标签: jsp struts2 ognl struts-tags