2011-06-23 42 views
1
<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">工作Struts 2迭代器标记状态索引不起作用

+1

尝试subType_type _%{#subTemplate.index}。 –

回答

1

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

0

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

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

我想:

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

,它是只有工作的人。

以下所有失败:

​​

即使

name="%{#rowStatus.index}"