我现在做一个BBS,做到主题页面,单行和双行颜色不要相同,也就是说,邻行颜色不能相同,怎么做?前辈们给思路

解决方案 »

  1.   

    我已经把数据放到 <logic:iterate id="list" name="topiclist">
      

  2.   

    <table>
    <logic:iterate id="list" name="topiclist" indexId="index">
    <tr bgcolor="${index mod 2 eq 0 ? '#222222' : '#444444'}">
    <td></td>
    </tr>
    </logic:iterate>
    </table>
      

  3.   


    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
    <html>
      <head>
        <title>My JSP 'index.jsp' starting page</title>
      </head>
      
      <body>
        <c:forEach begin="1" end="20" varStatus="vs">
        <c:choose>
        <c:when test="${vs.count%2 eq 0}">
        <div style="background:red">
        ${vs.count}
        </div>
        </c:when>
        <c:otherwise>
        <div style="background:blue">
        ${vs.count}
        </div>
        </c:otherwise>
        </c:choose>
        </c:forEach>
      </body>
    </html>
      

  4.   

    最简单的
    for(int i=0;i<list.size();i++){
      int a = i/2;  a = 1 一种情况  a = 0 一种情况}