当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
用freemarker标签实现一行五列的表格算法
发布时间:2010/6/7 11:08:45 来源:城市学习网 编辑:ziteng
  1 <table cellspacing="0" cellpadding="0" border="0" class="listTable">
  2 <#list tagPage.result as tag>
  3 <#-- 取5的模,即除于5的倍数余数为0的生成行的开头<tr> -->
  4 <#if tag_index%5==0><tr></#if>
  5    <td>
  6     &nbsp;<a href="post_bytag.action?tagId=${tag.id}">${tag.name}</a>(${tag.counts})&nbsp;
  7    </td>
  8    <#-- 如果最后一个不是刚好5列,则要补充完剩下的列 -->
  9 <#if tag_index == (tagPage.result?size-1) && tag_index%5!=4>
  10    <#assign end=(tagPage.result?size-tag_index+1) />
  11    <#-- 根据缺少的列数重新定义一个list生成列 -->
  12    <#list 0..end as x>
  13    <td>&nbsp;</td>
  14    </#list>
  15    </tr>
  16 </#if>
  17 <#-- 取5的模,即除于5的倍数余数为4(0到4刚好5列)的生成行的结尾</tr> -->
  18 <#if tag_index%5==4></tr></#if>
  19 </#list>
  20 </table>
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved