繁体   English   中英

图像未在 html thymeleaf springboot 中显示

[英]image is not showing in html thymeleaf springboot

我正在使用百里香和springboot

 I am not able to view any images in my HTML file. I have tried all different ways of doing 
 the same in thymeleaf but no luck.

 Here is my project folder structure

   🗁 src
    └─── 🗁 main
            └─── 🗁 resources
                      ├─── 🗁 templates
                      ├─── 🗁 css
                      └─── 🗁 images

在 HTML 文件中,我使用:

 <img src="/src/main/resources/static/image.png" alt="images">

在尝试了很多事情之后我终于得到了答案

Spring Boot's default configuration come that, your images (and other static 
content), need to be in src/main/resources/static. For example, to serve content 
from /images put the files in src/main/resources/static/images

And i used it

<img th:src="@{/images/image.png}" alt="image" width="300" height="200">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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