2016-10-13 11 views
0

spring-bootとthymeleafをテンプレートとして使用してアプリケーションを開発しました。私の見解では 私はループ内で変数を使用しようとしましたが、うまく機能しません。これは私のコードのスニペットです。Thymleafテンプレートでsrcイメージの変数を使用する

<table > 
    <thead> 
     <tr> 
      <th>Type</th> 
      <th>Résumé</th> 
      <th>Contenu</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr th:each="subTask : ${lstOtherSubTasks}"> 
      <td><img th:src="@{/img/icons/${subTask.issueTypeId}.png}" title="TODO" />  // here the variable ${subTask.issueTypeId} not works 
      <p th:text="${subTask.issueTypeId}" /> here the value of the variable ${subTask.issueTypeId} is not null I get the good value 
      </td> 
      <td th:text="${subTask.resume}"></td> 
      <td th:text="${subTask.contenu}"></td> 
     </tr> 
    </tbody> 
</table> 

答えて

5

あなたがしているように式と文字列を混在させることはできません。これは動作します:

<img th:src="@{${'/img/icons/' + subTask.issueTypeId + '.png'}}" title="TODO" /> 
+0

おかげMetroidsを。できます –

関連する問題