<logic:iterate id="headInfo" name="customerForm" property="cusHeadListInfo.cusHeadInfo" indexId="index" offset="<%= nowPageRecOffset.toString() %>" length="<%= nowPageRecCnt.toString() %>">
  <%
     int pageIndex = index.intValue();
     int indexMod = (pageIndex % 2); 
  String bgColor = "";
     if (indexMod == 0) {
  bgColor = "";
  }
  else{
  bgColor = "BGCOLOR=\"#CCCCCC\"";
  }
  %>   <TD <%=bgColor%> WIDTH="70" class="list">
    <bean:write name="headInfo" property="custId"/>
  </TD>
  <TD <%=bgColor%> WIDTH="100" class="list">
    <bean:write name="headInfo" property="lastName"/><bean:write name="headInfo" property="firstName"/>
  </TD>
  <TD <%=bgColor%> WIDTH="130" class="list">
    <bean:write name="headInfo" property="commissionName"/>
  </TD>  </logic:iterate>

解决方案 »

  1.   

    不是树型,象xiaoyou(三尺剑)所说的我也会,但我不希望把逻辑判断放到页面上,有办法既利用struts又不需要放任何逻辑判断到JSP页面上就可以实现这种“阴阳色列表”吗??在整个网站里,我希望在JSP页面里仅仅放扩展标记,所有接口和判断都用类来完成
      

  2.   

    <!--loop begin-->
    <%
    int i=1;
    String[] bgcolors={TD_BGCOLOR,TD_BGCOLOR2};
    Iterator messages=topicBean.getMessages().iterator();
    while(messages.hasNext()){
    Message message=(Message)messages.next();
    i=1-i;
    %>
      <tr class="aa">
        <td  bgcolor="<%=bgcolors[i]%>" valign="top" cellpadding="5">
          &nbsp;&nbsp;<%=StringUtil.escapeHTMLTags(message.getU_name())%><BR>
          &nbsp;&nbsp;<!-- Registered: <BR>-  --><%=DateTimeUtil.shortFmt(message.getU_regtime())%>
        </td>
        <td  bgcolor="<%=bgcolors[i]%>" >
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
          <tr>
    <td class="aa">
              &nbsp;&nbsp;
      <%if(message.getM_iconid()>0){%><img src="img/icons/<%=message.getM_iconid()%>.gif" width=15 height=15 border="0"><%}%>
      &nbsp;<%=DateTimeUtil.shortFmt(message.getM_time())%>
    </td>      </tr>
          <tr>
    <td  colspan="2" height="1" bgcolor="#999999" class="aa">
    </td>
          </tr>
          <tr>
    <td colspan="2"  valign="top" class="aa">
    <BR>
    <p>
    <%=StringUtil.dspHtml(message.getM_content())%>
    </p>        </td>
          </tr>
          <tr>
    <td  colspan="2" height="1" bgcolor="#999999">
    </td>
          </tr>
        </table>
      </td>
      </tr>
    <%
    }
    %>
    <!--loop end-->