簡體   English   中英

對Thymeleaf中的hashMap使用動態鍵以及屬性

[英]Use Dynamic key for hashMap in Thymeleaf, along with attribute

我正在與Thymeleaf一起做我的第一個項目。 我的大部分工作都完成了……除了下面的部分。

<img th:attrappend="src='file:///' + ${entryImageMap['__${entry.id}__']}"></img>

這是我從Thymeleaf得到的錯誤

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "entryImageMap['83383894']" (template: "Report.html" - line 89, col 6)

我嘗試了一些細微的變化。 這是我解決各種錯誤的方法,現在還不清楚。

<img th:attrappend="src=file:///${entryImageMap.(entry.id)}"></img>
<img th:attrappend="src=file:///${entryImageMap[__${entry.id}__]}"></img>
<img th:attrappend="src='file:///' + ${entryImageMap[__${entry.id}__]}"></img>
<img th:attrappend="src='file:///' + ${entryImageMap['__${entry.id}__']}"></img>

這工作:

<img th:attrappend="src='file:///' + ${data.entryImageMap.get('__${entry.id}__')}"></img>

我犯了一個錯誤,即認為entryImageMap位於根目錄中。 而它在data對象內部。

如果我正確使用了data.entryImageMap ,那么上述data.entryImageMap情況就data.entryImageMap

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM