关于Struts的logic:iterator标签

05-07-06 wozuibt
请看下面代码:

<%
  float collectHour=0;
  Collection outputs=(Collection)request.getAttribute("outputs");
  Iterator itOps=outputs.iterator();
  while(itOps.hasNext()){
    OutputInfo oi=(OutputInfo)itOps.next();
    out.println("<tr>");
    out.println("<td class='td_font'>"+oi.getEmpName()+"</td>");
    out.println("<td class='td_font'>"+oi.getPartID()+"</td>");
    out.println("<td class='td_font'>"+oi.getPartName()+"</td>");
    out.println("<td class='td_font'>"+oi.getWorkID()+"</td>");
    out.println("<td class='td_font'>"+oi.getListID()+"</td>");
    out.println("<td class='td_font'>"+oi.getUnit()+"</td>");
    out.println("<td class='td_font'>"+oi.getPiece()+"</td>");
    out.println("<td class='td_font'>"+oi.getManHour()+"</td>");
    out.println("</tr>");

<font color='#ff0000'>collectHour+=oi.getManHour();</font>

  }
%>
<p>

转换成Struts:
<%
  float collectHour=0;
%>
<logic:iterate id="ops" name="outputs" scope="request">
<tr>
<td class="td_font"><bean:write name="ops" property="empName"/></td>
<td class="td_font"><bean:write name="ops" property="partID"/></td>
<td class="td_font"><bean:write name="ops" property="partName"/></td>
<td class="td_font"><bean:write name="ops" property="workID"/></td>
<td class="td_font"><bean:write name="ops" property="listID"/></td>
<td class="td_font"><bean:write name="ops" property="unit"/></td>
<td class="td_font"><bean:write name="ops" property="piece"/></td>
<td class="td_font"><bean:write name="ops" property="manHour"/></td>
</tr>
</logic:iterate>
<p>

我希望logic每循环一次,collectHour都加上manHour的值,也就是说第一段代码的红色字体部分应该怎么转换成Struts,请大家指点?

猜你喜欢