Freemarker循环的方式:
# sequence 可以是 数组、java.util.Collection、java.util.List、java.util.Set
[#list sequence as item]
${item}
获取序号(从0开始):${item_index} ${item_index + 1}
判断是否有下一个
[#if item_has_next]...还有下一个元素...[/#if]
[/#list]
# 从1到10循环
[#list 1..10 as i]
...
[/#list]
字符串分隔用freemarker内建方法split
:
[#list '1,2,3,4,5'?split(',') as num]
...
${num}
...
[/#list]
参考资料:FreeMarker快速入门