关键词:
The following has evaluated to null or missing
此错误表示模板中引用了值为null的数据,此类错误页面会提示错误在哪个模板的哪一行哪一列,如下所示:
{"code":500,"msg":"The following has evaluated to null or missing:\n==> Site.seoKeywords [in template \"swikoon_pc/template/index.template.html\" at line 13, column 11]\n\n----\nTip: It's the step after the last dot that caused this error, not those before it.\n----\nTip: 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</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??\n----\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: ${Site.seoKeywords} [in template \"swikoon_pc/template/index.template.html\" at line 13, column 9]\n----"}
解决方法:
确认引用的变量已正确添加到模板上下文中,且变量不是null值。
如果变量可为null值,找到错误的位置,通过在引用变量后添加 !'' 来设置null值默认转成空字符串,例如:${Site.seoKeywords!''}。
如果是 ${Content.title} 中的 Content 为null,则需要确认是否已在模板中初始化此变量。