什么是支柱 2 等价物 strut 1 逻辑:迭代标记属性属性



在 strut 1 中,我们使用 logic:iterate tag 来迭代列表。在定义此标签时,我们使用属性属性和此属性的 strut 1 调用 getter 方法来获取可迭代对象。支柱 2 中对同一件事的等效物是什么?

如下面的 strut 1 代码所示,我们使用 logic:iterate tag 来迭代可迭代对象。Strut 1 通过调用属性属性(在本例中为记录(的 getter 方法来获取此 itearble 对象,该方法由 name 属性(在本例中为 DataForm(定义。

即在下面的示例中,strut 1 在内部调用 DataForm 类中存在的 getRecords(( 方法来获取可迭代对象。

我们如何在支柱 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>

您可以为其使用 value 属性。 像这样:

<ol>
<s:iterator value="records">
<li><s:property value="userfileName"/></li>
</s:iterator>
</ol>

这将调用此列表的 getter 方法,并且在使用值属性时,它将为记录类中的那些字段调用 getter。

最新更新