[英]Thymeleaf and Spring Boot doesn't show image
用百里香做我的Spring Boot應用程序,而不是圖像,我僅看到圖像圖標。 我怎樣才能解決這個問題? 圖像在static-> images文件夾中
<table class="table table-striped">
<tr th:each="message : ${messages}">
<td th:text="${message.id}"></td>
<td th:text="${message.text}"></td>
<td th:text="${message.tag}"></td>
<td><img th:src="@{/images/thymeleaf.png}"/></td>
</tr>
</table>
使用這樣的配置。
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/img/**").addResourceLocations("file:resources/","file:images/","file:" + uploadPath + "/");
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
}
添加您要顯示圖像的所有位置。 不要在文件后使用/ :
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.