Struts 2迭代器标记状态索引不起作用

时间:2011-06-23 20:40:12

标签: struts2

<s:iterator value="podTemplate.subTypeTemplates" status="subTemplate">
  <s:textfield id='subType_type_#subTemplate.index' key="subType" label="Name"/>
</s:iterator>

#subTemplate.index没有被索引取代。但是,如果我在做     <s:property value="#subTemplate.index">正在运作

2 个答案:

答案 0 :(得分:1)

这是因为textfield的id属性是字符串类型,默认情况下字符串类型属性不会被解释为OGNL。正如史蒂文所说,你必须在你的案例%{}中使用subType_type_%{#subTemplate.index}来强制解释。

答案 1 :(得分:0)

我的迭代器看起来像这样:

<s:iterator id="list" value="optionList" status="rowStatus" >

我试过了:

<td>
    <input class="textInput required"type="text" name="optionList[${rowStatus.index}].option_id"/>
</td>

并且它是唯一有效的。

以下所有内容都失败了:

name="optionList[%{#rowStatus.index}].option_id"
name="%{optionList[#rowStatus.index].option_id}"

甚至

name="%{#rowStatus.index}"
相关问题