我使用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