繁体   English   中英

Thymeleaf和Spring Boot不显示图像

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM