freemarker list (长度,遍历,下标,嵌套,排序)

1. freemarker获取list的size : 

ArrayList list = new ArrayList();

Freemaker
<#if list ??> <#--加这个当list对象为空时就不会报一堆错误-->
${list?size}


2. list的遍历:

Javascript代码 收藏代码
<#list animals as being>

${being.name}${being.price}



3.list遍历中的下标序号:

_index是list的一个属性

<#list list as a>
${a_index}


4. list的嵌套:

<#list jsskList as jsskVO>
<#list kcList as kcVO>
<#if kcVO.kch=jsskVO.kch> (kcVO里有编号和名称,而jsskVO里只有编号)
${kcVO.kcm}





5. list排序:
升序 .sort_by()

<#list list?sort_by("字段") as x>


降序 .sort_by()?reverse

<#list list?sort_by("字段")?reverse as x>



6. list标签遍历map:

<#list avertisementTypeMap?keys as key>

你可能感兴趣的:(front,freemarker,list,长度,遍历,下标,嵌套)