freeMarker中list的两列展示

前台界面中我使用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>
原文地址:https://www.cnblogs.com/wangxiangstudy/p/4828054.html