在Freemarker中处理空值 [英] Handling null values in Freemarker
本文介绍了在Freemarker中处理空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Freemarker中处理null
值?当数据中存在null
值时,模板中会出现一些异常.
How to handle null
values in Freemarker? I get some exceptions in the template when null
values are present in data.
推荐答案
您可以使用??
测试运算符:
You can use the ??
test operator:
这将检查对象的属性是否不为空:
This checks if the attribute of the object is not null:
<#if object.attribute??></#if>
这将检查对象或属性是否不为空:
This checks if object or attribute is not null:
<#if (object.attribute)??></#if>
来源:FreeMarker手册
这篇关于在Freemarker中处理空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文