2016-08-14 10 views
0

私はThymeleafで初めてのプロジェクトを行っています。私の仕事の大半は終わったのですが、これを除いて以下の部分があります。ThymeleafのhashMapに動的キーを使用し、属性と共に使用

<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> 

答えて

0

これが働いた:

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

を私はentryImageMapがルートにあったと仮定の間違いを行っていました。それどころか、それはdataオブジェクトの中にあった。

data.entryImageMapを正しく使用した場合、上記のケースのほとんどはうまくいきませんでした。

関連する問題