每行有四列,每行的第一列要空出来,其余三列显示输出的数据。
使用<c:forEach ,怎么做出来呢?每行的第一列是一个<td>
<td width="8%" height="16"> </td>其余三列是显示checkbox
<td width="21%" align="left">
<input type="checkbox" name="rss_ids" id="rss_ids" value="${rss.id }"/>${rss.title }
</td>
使用<c:forEach ,怎么做出来呢?每行的第一列是一个<td>
<td width="8%" height="16"> </td>其余三列是显示checkbox
<td width="21%" align="left">
<input type="checkbox" name="rss_ids" id="rss_ids" value="${rss.id }"/>${rss.title }
</td>
<table id="table" width="393" border="1" height="37">
<c:forEach var="item" items="${list}">
<tr>
<td width="8%" height="16"> </td>
<td width="21%" align="left">
<input type="checkbox" name="rss_ids" id="rss_ids"
value="${rss.id }"/>${rss.title }
</td>
</tr>
</c:forEach>
<table id="table" width="393" border="1" height="37">
<c:forEach var="item" items="${list}">
<tr>
<td width="8%" height="16"> </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>
<!-- *********************循环信息资源列表*********************** -->
<c:forEach items="${map.value}" var="rss" varStatus="r">
<c:if test="${r.index%3==0}">
<td width="8%" height="16"> </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>
<!-- *********************循环信息资源列表*********************** -->这样的写法也不行
<c:forEach var="item" items="${list}">
<tr>
<td width="8%" height="16"> </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>
试验一下
<c:forEach items="${map.value}" var="rss" varStatus="r">
<c:if test="${r.index%4==1}">
<td width="8%" height="16"> </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>
这种写法,把每个
<input type="checkbox" name="rss_ids" id="rss_ids"
value="${rss.id }"/>${rss.title }
都显示了三列
<tr>
<c:forEach items="${map.value}" var="rss" varStatus="r">
<td width="8%" height="16"> </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>
改一下
<td width="8%" height="16"> </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"> </td>
</c:if>
</c:forEach>
检查一下你的数据吧。
第一列只显示一个<td>就换行了。
<td width="8%" height="16"> </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"> </td>
</c:if>
</c:forEach>看看这样行不
每行显示4列,每行的第一列是空的,其他三列都要显示集合中的数据。
例如:集合中的数据只有1条,那么第一列是&bsp;填充,第二列是数据,其他列以&bsp;填充
集合中的数据有2条,那么第一列是&bsp;填充,第二列是数据,第三列也是数据,第四列以&bsp;填充
集合中的数据有4条,那么第一列是&bsp;填充,第二列是数据,第三列也是数据,第四列也是数据,开始换行,新行的展示如同上述。