1
我想重构我的代码,我正在寻找动态设置<s:textfield>
的关键属性的可能性。Struts2 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()'/>"/>
但这些都不起作用,我没有找到关于动态密钥属性的任何信息。有谁知道一个解决方案?