您的位置:首页 > 其它

freeMarker中list的两列展示

2015-09-22 09:43 148 查看
前台界面中我使用freeMarker的机会有很多,自然也就会接触下<List>标签,我想大家应该都不陌生。<#list attrList as attr>${a.name}</#list>类似的用法很多,但是偶尔会用到两列的展示效果我们改怎么办呢?我们可以根据模型中的int类型的某一列,一般是自动增长的id标识列。如果你设计的表中 没有这样类型的列,那么就不用往下看了。

<#list attrList as attr>
<#if attr_index%2 ==0>
<#if attr_index==0>
<tr>
<#else>
</tr><tr>
</#if>
</#if>
<th width="118">${attr.key!}:</th>
<td>${attr.value!}</td>
<#if attr_index==attrList?size-1>
<#if attr_index%2 ==1>
</tr>
<#else>
<th width="118"></th>
<td></td></tr>
</#if>
</#if>
</#list>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: