日期:2014-05-18  浏览次数:20631 次

在线等,如何利用jsp标签动态创建多列表格..我等了老半天了,还是不行.
<table   width= "90% "   border= "1 "   cellspacing= "0 "   cellpadding= "0 ">

<c:forEach   items= "${QUERY_SITES_BY_LOGGING_REGION_ID.dataList} "   var= "row "   step= "3 ">
<tr>
<td>    
<html:multibox   property= "siteIds ">
<c:out   value= "${row.ID} "> </c:out>
                  </html:multibox>
<c:out   value= "${row.CHNAME} "> </c:out>
  </td>
  </tr>
</c:forEach>
    </table>
这样只能生成一列N多行的表格,我想把它搞成5列N行,或10列N行,每列就是一个复选框


------解决方案--------------------
<tr>
<td>
<html:multibox property= "siteIds ">
<c:out value= "${row.ID} "> </c:out>
</html:multibox>
<c:out value= "${row.CHNAME} "> </c:out>
</td>
</tr>

====
一个 <td> 代表一列
你可以这样
<tr>
<td>
<html:multibox property= "siteIds ">
<c:out value= "${row.ID} "> </c:out>
<td> <!--注意这里加个td就是一列-->
</html:multibox>
<c:out value= "${row.CHNAME} "> </c:out>
</td>
</tr>

------解决方案--------------------
临时看了下JSTL,不一定对,仅供参考吧

<table width= "90% " border= "1 " cellspacing= "0 " cellpadding= "0 ">

//////////////////
//在这里插入一个变量,并赋初值
<c:set var= "thenum " value= "0 "/>
<tr>
// <tr> 拿到forEach外面,否则还是一个记录一行.
//////////////////

<c:forEach items= "${QUERY_SITES_BY_LOGGING_REGION_ID.dataList} " var= "row " step= "3 ">
<td>
<html:multibox property= "siteIds ">
<c:out value= "${row.ID} "> </c:out>
</html:multibox>
<c:out value= "${row.CHNAME} "> </c:out>
</td>

//////////////////
//在这里对前面设置的变量增1,并判断是否达到规定列数(比如是5),达到就另起一行
<c:if test= "${thenum> 4} ">
</tr> <tr>
</c:if>
//////////////////

</c:forEach>
</tr>
</table>

------解决方案--------------------
忘了增1了

//////////////////
//在这里对前面设置的变量增1,并判断是否达到规定列数(比如是5),达到就另起一行
<c:set var= "thenum " value= "${thenum}+1 "/> ////这个格式不知对不对
<c:if test= "${thenum> 4} ">
</tr> <tr>
</c:if>
//////////////////