我試圖通過HashMap<SeapSubscription, List<PiNotice>>
在freemarker模板中進行迭代。 該地圖不包含任何空值(按鍵或值)。迭代對象的映射:Freemarker中的列表
在Freemarker的代碼是:
<#list subscriptionsWithPiNotices?keys as s>
${s.title}
<#list subscriptionsWithPiNotices[s] as piNotice>
Autoritate contractanta: ${piNotice.contractingAuthorityName}
.
.
</#list>
</#list>
如果我從第二列表(< #list subscriptionsWithPiNotices [秒]作爲piNotice>)所有的工作除去迭代(即遍歷映射鍵,但是當我添加第二個部分,試圖遍歷地圖的價值,我得到一個空/缺失異常
FreeMarker template error: The following has evaluated to null or missing:
==> subscriptionsWithPiNotices [S] [模板「SEAP訂閱快訊.ftl」在第21行,第16欄第]
提示:如果發生故障的表達已知是合法空/缺少, 要麼指定與myOptionalVar myDefault的默認值,或使用 <的#if myOptionalVar ??>時,本! < #else>失蹤時。 (這些 僅覆蓋表達的最後步驟;以覆蓋整個 表達,使用parenthessis:(myOptionVar.foo)myDefault, (myOptionVar.foo)??
的失敗指令(FTL堆棧跟蹤)! :
==> #list subscriptionsWithPiNotices [s] a ... [在模板「seap-subscription-newsletter.ftl」第21行,第9列] #list subscriptionsWithPiNotices?keys ... [in template「 seap-subscription-newsletter.ftl「在第18行第5列]
我再說一遍, hMap,它只有一個關鍵字,其中一個ArrayList裏面有一個項目。所以沒有理由報告一個空,是嗎?
這是FTL的年齡問題,它沒有'Map'類型。它有一個「散列」類型,但只支持「字符串」鍵(用於子變量)。然後'BeansWrapper'靜靜地將'toString()'s's'作爲'[]'需要一個字符串,然後它當然不會找到'Map'條目......你會發現一些關於可能的SO答案解決方法。 – ddekany
密鑰的類型是什麼? –