freemarker list (长度,遍历,下标,嵌套,排序)
1.freemarker获取list的size:
${list?size}
2.list的遍历:
<#list animals as being> <tr> <td>${being.name}${being.price}<td> </tr> </#list>
3.list遍历中的下标序号:
_index是list的一个属性
<#list list as a> ${a_index} </#list>
4.list的嵌套:
<#list jsskList as jsskVO> <#list kcList as kcVO> <#if kcVO.kch=jsskVO.kch> (kcVO里有编号和名称,而jsskVO里只有编号) ${kcVO.kcm} </#if> </#list> </#list>
5.list排序:
升序.sort_by()
<#list list?sort_by("字段") as x> </#list>
降序.sort_by()?reverse
<#list list?sort_by("字段")?reverse as x> </#list>
6.list标签遍历map:
<#list avertisementTypeMap?keys as key> <option value="${key}">${avertisementTypeMap[key]}</option> </#list>
<#assign numbers = ["一","二","三"] + ["四","五","六"]+["七","八","九","十"]/> <#assign page = 2 /> <#assign pageNum = 10 /> <#assign n = (page-1)*pageNum /> <#list numbers as x> <#assign n = n+1 /> ${n}:${x}:${x_index+1}<br /> </#list>
相关推荐
81314797 2020-11-18
89314493 2020-11-03
81941231 2020-09-17
thisisid 2020-09-09
如狼 2020-08-15
82384399 2020-06-16
86384798 2020-05-12
80183053 2020-05-02
86384798 2020-04-26
86384798 2020-04-11
rionchen 2020-04-09
86384798 2020-04-07
86384798 2020-04-04
80183053 2020-03-07
87201943 2020-03-06
83961233 2020-02-26
87201943 2020-02-21