FreeMarker语法
1. 查找转移
<#function getSubSlot x >
<#return (x) ? switch(
"1", "L",
"2", "R",
""
)>
</#function>
2. 转换数字
?number
${mergedMap[placement.sequence].material.subslot?number-1}
3. 截取字符串
substring
方法的表达式为?substring(from, to)
4. 时间格式转换
<timestamp value="${head.time?datetime("yyyyMMddHHmmss.SSS")?string('dd/MM/yyyy hh:mm:ss')}" />
5. 判断变量是否在结构体中存在
<#if (partsMap?size > 0) && (!partsMap[position.partId]?exists)>
6. 数组中加变量
<#assign myArray = [] />
<#assign myArray += ["element2"] />
7. 跳过List循环
<#list listOfNumbers as num>
<#if num == 3>
<#continue>
</#if>
Number: ${num}<#if num != listOfNumbers?last>, </#if>
</#list>