前台界面中我使用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
最后
以上就是自由电源最近收集整理的关于freeMarker中list的两列展示的全部内容,更多相关freeMarker中list内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复