- 用于页面显示 (默认值)
<!-- 感叹号后为默认值 如 '20130823' --> <span class="info-date">${old_order_startTime!'20130823'}
- 用于if判断
<!--unsafe_expr??或(unsafe_expr)??--> <#if orderInfo.couponList??> <#list orderInfo.couponList as ite> <p> - 红包: ¥${ite.couponPay} </p> </#list> </#if>
<#if mouse??> Mouse found <#else> No mouse found </#if> Creating mouse... <#assign mouse = "Jerry"> <#if mouse??> Mouse found <#else> No mouse found </#if>
- 判断时也可以使用默认值
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>freemarker demo</title> </head> <body> ${username} <br /> ${age}<br /> ${sex!} <#if (sex!23) ==23 > ok <#else> no </#if> </body> </html>
必须是同类型的比较 否则会报错如: int 和string 类型比较会报错