if…elseif…else
<#if student.studentAge lt 12>
${student.studentName}不是一个初中生
<#elseif student.studentAge lt 15>
${student.studentName}不是一个高中生
<#elseif student.studentAge lt 18>
${student.studentName}不是一个大学生
<#else>
${student.studentName}是一个大学生
</#if>
遍历list
<#if vOList?? && (vOList?size gt 0)>
<#list vOList as data>
<tr>
<td>${data.sort!}</a></td>
<td>${data.name!}</td>
<#if !hideLink>
<#if data.viewPath=="无" >
<td>无</td>
<#else>
<td><a href=${data.viewPath!}>查看详情</a></td>
</#if>
</#if>
</tr>
</#list>
</#if>
List<String> aList = new ArrayList<>();
aList.add("aaa");
aList.add("bbb");
aList.add("cccc");
aList.add("dddd");
List<String> bList = new ArrayList<>();
bList.add("1211");
bList.add("2323");
bList.add("34334");
bList.add("45455");
List<List<String>> list= new ArrayList<>();
list.add(aList);
list.add(bList);
paramMap.put("list", list);
<table class=MsoNormalTable style="border-collapse:collapse;width:303.7000pt;mso-table-layout-alt:fixed;mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;" >
<#if list?? && (list?size gt 0)>
<#list list as data>
<#assign parm = data />
<tr style="height:14.4000pt;" >
<#list parm as item>
<td width=328 valign=center style="width:164.2500pt;padding:0.0000pt 5.4000pt 0.0000pt 5.4000pt ;border-left:1.0000pt solid windowtext;mso-border-left-alt:0.5000pt solid windowtext;border-right:1.0000pt solid windowtext;mso-border-right-alt:0.5000pt solid windowtext;border-top:31.8750pt none rgb(255,255,255);mso-border-top-alt:31.8750pt none rgb(255,255,255);border-bottom:31.8750pt none rgb(255,255,255);mso-border-bottom-alt:31.8750pt none rgb(255,255,255);" >
<p class=MsoNormal align=right style="mso-pagination:widow-orphan;text-align:right;" >
<span style="mso-spacerun:'yes';font-family:宋体;color:rgb(0,0,0);font-size:11.0000pt;mso-font-kerning:0.0000pt;" >${item}</span>
<span style="font-family:宋体;color:rgb(0,0,0);font-size:11.0000pt;mso-font-kerning:0.0000pt;" >
<o:p></o:p>
</span>
</p>
</td>
</#list>
</tr>
</#list>
</#if>
</table>
取的list长度
<#list properties as item>
<#assign layer = item.dispalyName?split(",") />
<#assign number = layer?size />
<#assign width = 70*number />
<Column ss:Index="${count}" ss:Width="${width}" />
<#assign count = count + 1>
</#list>
对于null,或者miss value,freemarker会报错
!:default value operator,语法结构为:unsafe_expr!default_expr,比如 ${mouse!"No mouse."} 当mouse不存在时,返回default value;
(product.color)!"red" 这种方式,能够处理product或者color为miss value的情况;
而product.color!"red"将只处理color为miss value的情况
??: Missing value test operator ,测试是否为missing value
unsafe_expr?? :product.color??将只测试color是否为null
(unsafe_expr)??:(product.color)??将测试product和color是否存在null
?exists:旧版本的用法
比如:<#if mouse??>
Mouse found
<#else>
No mouse found
</#if>
Creating mouse...
<#assign mouse = "Jerry">
<#if mouse??>
Mouse found
<#else>
No mouse found
</#if>