每行有四列,每行的第一列要空出来,其余三列显示输出的数据。
使用<c:forEach ,怎么做出来呢?每行的第一列是一个<td>
<td width="8%" height="16">&nbsp;</td>其余三列是显示checkbox
<td width="21%" align="left">
<input type="checkbox" name="rss_ids" id="rss_ids" value="${rss.id }"/>${rss.title }
</td>

解决方案 »

  1.   


    <table id="table" width="393" border="1" height="37">
    <c:forEach var="item" items="${list}">
    <tr>
    <td width="8%" height="16">&nbsp;</td>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" 
    value="${rss.id }"/>${rss.title }
    </td>
    </tr>
    </c:forEach>
      

  2.   


    <table id="table" width="393" border="1" height="37">
    <c:forEach var="item" items="${list}">
    <tr>
    <td width="8%" height="16">&nbsp;</td>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" 
    value="${item.id }"/>${item.title }
    </td>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" 
    value="${item.id }"/>${item.title }
    </td>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" 
    value="${item.id }"/>${item.title }
    </td>
    </tr>
    </c:forEach>
      

  3.   

    我的<c:forEach 循环式在<tr>标签内的

    <!-- *********************循环信息资源列表*********************** -->
    <c:forEach items="${map.value}" var="rss" varStatus="r">

    <c:if test="${r.index%3==0}">
         <td width="8%" height="16">&nbsp;</td>
    </c:if>

    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" value="${rss.id }"/>${rss.title }
    </td>

    <c:if test="${r.index%2==0 && r.index!=0}">
    <tr></tr>
    </c:if>

    </c:forEach>
    <!-- *********************循环信息资源列表*********************** -->这样的写法也不行
      

  4.   

    <table id="table" width="393" border="1" height="37">
    <c:forEach var="item" items="${list}">
    <tr>
    <td width="8%" height="16">&nbsp;</td>
    <c:forEach begin="0" end="2">
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" 
    value="${rss.id }"/>${rss.title }
    </td>
    </c:forEach>
    </tr>
    </c:forEach>
    试验一下
      

  5.   


    <c:forEach items="${map.value}" var="rss" varStatus="r">
    <c:if test="${r.index%4==1}">
     <td width="8%" height="16">&nbsp;</td>
    </c:if>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids" value="${rss.id }"/>${rss.title }
    </td>
    <c:if test="${r.index%4==0&&r.index!=0}">
    <tr></tr>
    </c:if>
    </c:forEach>
      

  6.   


    这种写法,把每个
    <input type="checkbox" name="rss_ids" id="rss_ids"  
    value="${rss.id }"/>${rss.title }
    都显示了三列
      

  7.   

    <table>
    <tr>
    <c:forEach items="${map.value}" var="rss" varStatus="r">
      <td width="8%" height="16">&nbsp;</td>
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids"  value="${rss.id }"/>${rss.title }
    </td><c:if test="${r.index%3==0}">
    </tr><tr>
    </c:if>
    </c:forEach>
    </tr>
    </table>
      

  8.   

    index貌似不行吧。用count试试。<c:if test="${r.count%3==0}">
      

  9.   

    刚才贴错了
    改一下
    <td width="8%" height="16">&nbsp;</td>
    <c:forEach items="${map.value}" var="rss" varStatus="r">  
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids"  value="${rss.id }"/>${rss.title }
    </td>
    <c:if test="${r.index%3==0}">
    </tr><tr>
    <td width="8%" height="16">&nbsp;</td>
    </c:if>
    </c:forEach>
      

  10.   

    你的rss里只有id和title吗,如果不是看看你的数据里id和title是不是有重复的。
      

  11.   

    title没有重复的?效果已经有了,第一列是空,后面有3列是吧
    检查一下你的数据吧。
      

  12.   


    第一列只显示一个<td>就换行了。
      

  13.   


    <td width="8%" height="16">&nbsp;</td>
    <c:forEach items="${map.value}" var="rss" varStatus="r">   
    <td width="21%" align="left">
    <input type="checkbox" name="rss_ids" id="rss_ids"  value="${rss.id }"/>${rss.title }
    </td>
    <c:if test="${r.index!=0&&r.index%3==0}">
    </tr><tr>
    <td width="8%" height="16">&nbsp;</td>
    </c:if>
    </c:forEach>看看这样行不
      

  14.   

    补充一下我想要的效果:
         每行显示4列,每行的第一列是空的,其他三列都要显示集合中的数据。
    例如:集合中的数据只有1条,那么第一列是&bsp;填充,第二列是数据,其他列以&bsp;填充      
          集合中的数据有2条,那么第一列是&bsp;填充,第二列是数据,第三列也是数据,第四列以&bsp;填充
          集合中的数据有4条,那么第一列是&bsp;填充,第二列是数据,第三列也是数据,第四列也是数据,开始换行,新行的展示如同上述。
      

  15.   

    判断一下,没有数据的话。显示一个&nbsp;  显示的直接现实数据 就ok了。