Struts 2 iterator tag status index is not working
<s:iterator value="podTemplate.subTypeTemplates" status="subTemplate">
<s:textfield id='subType_type_#subTemplate.index' key="subType" label=开发者_运维百科"Name"/>
</s:iterator>
#subTemplate.index
is not getting replaced by index. However if I am doing
<s:property value="#subTemplate.index">
is working
That's because id
attribute of textfield is of string type and string-type attributes are not interpreted as OGNL by default. As Steven said you have to force the interpretation by using %{}
in your case subType_type_%{#subTemplate.index}
.
My iterator looks like this:
<s:iterator id="list" value="optionList" status="rowStatus" >
I tried:
<td>
<input class="textInput required"type="text" name="optionList[${rowStatus.index}].option_id"/>
</td>
and it's the only one that worked.
All the following ones failed:
name="optionList[%{#rowStatus.index}].option_id"
name="%{optionList[#rowStatus.index].option_id}"
even
name="%{#rowStatus.index}"
精彩评论