${var!}
适用类型:对 null 或者不存在的对象进行取值,可以设置默认值,例:${var!'我是默认值'} 即,有值时显示正常值,无值时显示默认值
示例:
在后台文件中定义变量
String strVar = "世界你好";
String str = null;
在页面中获取变量:
String获取:<font color="red"> ${strVar!"我是空"} </font><br>
str获取:<font color="red"> ${str!} </font><br>
str获取:<font color="red"> ${str!"默认"} </font><br>
展示结果:
String获取:世界你好
str获取:
str获取:默认
判断time不为null 不能判断 " "
<#if time??>
`year_month` as time,
</#if>