freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]


FreeMarker template error:
The following has evaluated to null or missing:
==> product  [in template "product.html" at line 751, column 43]

 

FreeMarker模板誤差:
以下已評估為null或丟失:
=產品“模板”產品HTML“在第751行,第43欄]

----------------------------

意思是有個值為null,就是不存在,

 

 

Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??

 

Tip: If the failing expression is known to be legally null/missing, either specify a default value with 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 parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
-----------------
提示:如果沒有表達是合法的空/失蹤,或者指定一個默認值myoptionalvar!mydefault,或使用< #如果myoptionalvar??>在< #別的>當失蹤/ # <<如果>>。(這些僅覆蓋的表達;最后一步覆蓋整個表達式,使用parenthessis:(myoptionvar。Foo)!mydefault,(myoptionvar。Foo)?
 
大概意思是應該進行判斷,對象是否為空

 

 

 

 

 

一般出現這種異常的原因為:如果對象為空,則freemarker就會拋出這個異常。

其實解決很簡單,在用對象之前先判空,不空在進行屬性的獲取操作即可

 

原文地址


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM