1、 使用感叹号
Invoice Date: ${(customer.invoice.date)!}
感叹号告诉 FreeMarker 对表达式自动检查 null 值和空字符串。如果 customer、invoice 或者 date 中有一个为空值或空字符串,你只会得到标签:
Invoice Date:
另一个选择是感叹号后包括你的默认值。
Invoice Date: ${(customer.invoice.date)!'No Invoice Available'}
如果所有值丢失,你会得到:
Invoice Date: No Invoice Available
注:https://blog.csdn.net/guoshijie1993/article/details/72622059
https://freemarker.apache.org/docs/dgui_template_exp.html
http://freemarker.foofun.cn/dgui_template_exp.html