开发者

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}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜