<#--Freemarker遍历list并应用list隐含变量item_index--> item_index使用: <#list userList as user> 第${user_index+1}个用户 用户名:${user.userName} 密码:${user.userPassword} 年龄: ${user.age} </#list> <#--Freemarker遍历list并应用list隐含变量item_has_next--> item_has_next,size使用: <...
<#list toplist as toplists> ${toplists_index} </#list> 相当方便
${item.username} </#list> 其中sequence是变量名,它代表一个list。item是我起的别名,遍历的时候,它代表LIST中的一项。 获取索引值: Html代码 <#list sequence as item> ${item_index} </#list> 索引值的获取是"别名_index"的形式。如果你起的别名是user那么就用“user_index”。 需要说明的是索引值是从...
FreeMarker - 常用指令和宏 【1】list、break指令 语法格式如下: <#list sequence as item>...</#list> item_index:当前变量的索引值. item_has_next:是否存在下一个对象. 示例如下: <#list ["星期一","星期二","星期三","星期四","星期五","星期六"] as x>${x_index + 1}.${x}<#if x_...
list[index] 显示序列index索引处的元素 start…end 定义值域,1…3表示[1,2,3]序列;3…1表示[3,2,1]序列 start…<end或start…!end 不包含尾部,1…3表示[1,2]序列 start…*length 指定长度,5…*3表示[5,6,7]序列;5…*-3表示[3,4,5]序列 ...
item_index:当前迭代项在所有迭代项中的位置,是数字值。 item_has_next:用于判断当前迭代项是否是所有迭代项中的最后一项。 注意:在使用上述两个循环变量时,一定要将item换成你自己定义的循环变量名,item其实就是前缀罢了。 例如,如果你使用<# list list as l>..定义,那么就要使用l_index,l_has_next。在循环...
3>.list、break指令 <#list sequence as item> ... </#list> * item_index :当前变量的索引值. * item_has_next :是否存在下一个对象. 例子: <#list ["星期一","星期二","星期三","星期四","星期五","星期六"] as x> ${x_index + 1}.${x} ...
List指令还隐含了两个循环变量:item_index:当前迭代项在所有迭代项中的位置,是数字值。item_has_next:⽤于判断当前迭代项是否是所有迭代项中的最后⼀项。注意:在使⽤上述两个循环变量时,⼀定要将item换成你⾃⼰定义的循环变量名,item其实就是前缀罢了。例如,如果你使⽤<# list list as l>..<...
a、item_index:当前变量的索引值。b、item_has_next:是否存在下一个对象 也可以使用<#break>指令跳出迭代<#list["星期一","星期二","星期三","星期四","星期五"]asx>${x_index+1}.${x}<#ifx_has_next>,</#if><#ifx="星期四"><#break></#if></#list> ...
<#list strings?sort as str> ${str} 输出list下标:${str_index} </#list> 已排序:--> 调用已存在的排序方法 -->降序 <#list strings?sort?reverse as str> ${str} 输出list下标:${str_index} </#list> list长度:${strings?size} 下标取值:${strings[0]} Ps: <#list myList?sort?reverse...