I have a JSP in which I am iterating over a list and creating an editable table.
-
You need the Country object is created when the params interceptor is populating your list using indexed property access.
<s:iterator value="test" id="countryList" status="stat">
<tr>
<td><s:textfield name="countryList[%{#stat.index}].countryCode" value="%{countryCode}" theme="simple" /></td>
<td><s:textfield name="countryList[%{#stat.index}].countryName" value="%{countryName}" theme="simple" /></td>
</tr>
</s:iterator>
To let the struts populate the list you should use a type conversion annotation or equivalent in the xml configuration.
@Element(value = Country.class)
@Key(value = String.class)
@KeyProperty(value = "countryCode")
@CreateIfNull(value = true)
private List<Country> countryList = new ArrayList<Country>;
讨论(0)
- 热议问题