【问题标题】:Freemarker If condition is NULLFreemarker 如果条件为 NULL
【发布时间】:2019-04-04 15:40:00
【问题描述】:

我只想要一个没有结束日期的学校列表。在 SQL 中我总是使用条件is null,它在 Freemarker 中是如何工作的?

<#list mergevelden.adres_instantie_344.betrokken_instanties.betrokken_instantie as scholen><br>
***<#if scholen.tm="null">***
${scholen.instantie.volledige_naam}
${scholen.instantie.adressen.adres.straat} ${scholen.instantie.adressen.adres.huisnummer}
${scholen.instantie.adressen.adres.postcode}  ${scholen.instantie.adressen.adres.woonplaats?upper_case}<br>
</#if>
</#list>

【问题讨论】:

标签: if-statement conditional-statements freemarker


【解决方案1】:

scholen.tm?? 告诉scholen.tm 是否存在(不是null)。所以这与您所要求的相反,但您可以将其反转为!scholen.tm??。但是对于存在scholen.tm 的情况,最好使用#if 分支,然后在不存在的情况下使用#else 分支。

另请注意,在许多情况下,您可以避免使用#if。就像您只想要一个默认值一样,您可以执行foo.bar!'The default if bar is null' 之类的操作。

【讨论】:

    猜你喜欢
    • 2012-11-04
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2020-06-02
    • 2018-04-13
    • 2022-06-15
    • 2014-10-01
    • 2014-06-19
    相关资源
    最近更新 更多