FreeMarker if 语句比较两个值
FreeMarker if statement comparing two values
我正在尝试比较两个值
<#if user.cellPhone != changedUser.cellPhon>
<br><span class="changes">*${changedUser.cellPhone}</span></#if>
我遇到错误
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:==> changeUser
提示:
If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
为条件添加 null 检查 changedUser??
:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>
我正在尝试比较两个值
<#if user.cellPhone != changedUser.cellPhon>
<br><span class="changes">*${changedUser.cellPhone}</span></#if>
我遇到错误
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:==> changeUser
提示:
If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
为条件添加 null 检查 changedUser??
:
<#if changedUser?? && user.cellPhone != changedUser.cellPhon>