我使用Spring Boot,飛碟,百里香葉從html模板創建了一個文件pdf。但圖像不顯示在我的文件中。使用Spring Boot,飛碟和百里香葉在PDF模板中顯示圖像
項目結構:
代碼的html:
<div class="col-xs-6 invoice-col-2">
<img src="../static/images/mastercard.png" alt="mastercard"></img>
</div>
當我改變img標籤:
<img src="../static/images/mastercard.png" alt="mastercard" th:src="@{static/images/mastercard.png}"></img>
瓦恩,我創建的PDF文件,我得到一個錯誤:
org.thymeleaf.exceptions.TemplateProcessingException: Link base "static/images/mastercard.png" cannot be context relative (/) or page relative unless you implement the org.thymeleaf.context.IWebContext interface (context is of class: org.thymeleaf.context.Context)
嘗試使用絕對路徑或在'img'tag –
中感謝您的響應,使src =「/ images/mastercard.png」成爲''。我嘗試在img標籤中更改src =「/ images/mastercard.png」,但不顯示圖像。我在img標籤中使用
並顯示。我剛剛做到了。 :)) –
dinhbao10t4