Tom*_*lst 85
您可以使用??测试运算符:
这将检查对象的属性是否为null:
<#if object.attribute??></#if>
这将检查对象或属性是否为null:
<#if (object.attribute)??></#if>
资料来源:FreeMarker手册
Arn*_*aud 83
从freemarker 2.3.7开始,您可以使用以下语法:
${(object.attribute)!}
Run Code Online (Sandbox Code Playgroud)
或者,如果要在属性为null以下时显示默认文本:
${(object.attribute)!"default text"}
Run Code Online (Sandbox Code Playgroud)
我认为反之亦然
<#if object.attribute??>
Do whatever you want....
</#if>
Run Code Online (Sandbox Code Playgroud)
如果object.attribute不为NULL,则打印内容。
| 归档时间: |
|
| 查看次数: |
111367 次 |
| 最近记录: |