我遇到了一个Struts 1表单的问题,它包含一个逻辑:iterate负责创建行,每个行都有一个输入按钮。 问题出现时,我打任何的提交按钮,动态数据不能正常公布和形式不具有这些值,这里有一个例子:Struts 1 - 行提交
<html:form action="/myAction" styleClass="centeredForm" style="display:inline" >
<td class="formLabel">City</td>
<td class="formControl">
<bean:define id="cities" name="myForm"
property="cities" type="java.util.Collection"/>
<html:select styleClass="dashSelect" property="city">
<html:option value="">All Cities</html:option>
<html:options collection="cities"
property="id" labelProperty="value"/>
</html:select>
</td>
... Other elements ...
<logic:iterate id="myObject" name="myForm" property="myObjects" indexId="index" type="com.test.MyObject">
<% String rowClass = index.intValue() % 2 == 0 ? "even-row" : "odd-row"; %>
<tr class="<%=rowClass%>">
<td class="result-cell"><bean:write name="myObject" property="id" /> </td>
<td class="result-cell"><bean:write name="myObject" property="name" /> </td>
<td class="result-cell">
<html:select styleClass="dashSelect" name="myObject" property="status">
<html:option value="F">Disabled</html:option>
<html:option value="T">Enabled</html:option>
</html:select>
</td>
<td>
<html:submit/>
</td>
“城市”部分和在逻辑之外休息:迭代,在“myForm”上出现得很好,但“myObject”不是。我甚至尝试用JavaScript函数提交,但无法正常工作。 目前,我所拥有的(HTML:提交我留下作为参考)导致POST包含一堆“状态”参数和我前面提到的正确值。
任何人都可以对此有所了解吗?
让我知道你是否需要更多信息。
非常感谢!
不确定你的意思;你没有使用'indexed'标签(参见[这里](http://struts.apache.org/1.2.7/faqs/indexedprops.html))或者嵌套标签,也没有手动建立索引属性名称 - I尽管如此,还不完全清楚哪些部分无法正常工作。 (看起来在一些标签/ bean中也有很多额外的工作;你是否考虑过使用JSP EL或者至少是EL Struts标签,如果你使用的是过时的容器?) – 2012-01-09 21:51:01
问题是,当我点击提交时,表单没有填充“myObject”,这是我通过逻辑:iterate创建的每一行的信息。 我将在此期间看看索引标签。 – LdSe 2012-01-09 22:19:14