在strut 1中,我们使用logic:iterate标记迭代列表。在定义此标签时,我们使用属性属性和该属性的strut 1调用getter方法来获取Iterable Object。 strut 2中对同一事物的等效项是什么?
如下面strut 1中的代码所示,我们正在使用logic:iterate标记对可迭代对象进行迭代。然后Strut 1调用属性name(在此示例中为record)定义的getter方法(此示例中为DataForm)来获取该itearble对象。
即在下面的示例中,strut 1在内部调用DataForm类中存在的getRecords()方法来获取可迭代对象。
我们如何在strut 2中实现相同的目标?
<div STYLE=" height: 300px; width: 860;font-size:12px; overflow: auto;">
<html:form action="/discardHorisBulk.do" target="content">
<table width="840">
**<logic:iterate id="horisList" name="DataForm" property="records" indexId="indexId" type="com.waghtech.client.isTech.model.Horis" >**
<tr>
<%
String bgColor="#fffafa";
int size = indexId.intValue();
if (indexId.intValue() %2 == 0)
{
bgColor="#dcdcdc";
}
java.util.HashMap params = new java.util.HashMap();
params.put("key", horisList.getKey() );
params.put("clientName", horisList.getClientName() );
pageContext.setAttribute("paramsName", params);
%>
<td bgcolor=<%=bgColor%> width="200">
<html:link page="/mapClient.do" name="paramsName" scope="page" >
<bean:write name="horisList" property="clientName"/>
</html:link>
</td>
<td bgcolor=<%=bgColor%> width="60">
<bean:write name="horisList" property="startDate"/>
</td>
<td bgcolor=<%=bgColor%> width="60">
<bean:write name="horisList" property="endDate"/>
</td>
<!--
<td bgcolor=<%=bgColor%> width="200">
<bean:write name="horisList" property="displayFd"/>
</td>
-->
<td bgcolor=<%=bgColor%> width="200">
<bean:write name="horisList" property="userfileName"/>
</td>
<td bgcolor=<%=bgColor%> width="40">
<html:multibox name="dataForm" property="markedRecords" value="<%=horisList.getClientName()%>">
<bean:write name="horisList" property="key"/>
</html:multibox>
</td>
</tr>
</logic:iterate>
</table>
</div>
答案 0 :(得分:0)
您可以为其使用值属性。像这样的东西:
<ol>
<s:iterator value="records">
<li><s:property value="userfileName"/></li>
</s:iterator>
</ol>
这将调用此列表的getter方法,在使用value属性的方法中,它将为记录类中的那些字段调用getter。