图像不加载百里角

发布于 2025-02-01 03:40:57 字数 494 浏览 3 评论 0原文

我正在尝试使用Thymeleaf的电子邮件中加载项目本地存储的图像,但不会!

    <img src="../static/img/logo.png" alt="MyPicture" th:src="@{img/logo.png}">

虽然当我尝试使用绝对路径时,它完美地加载

    <img src="C:/Workspace/myProject/src/main/resources/static/img/logo.png" alt="MyPicture">

了我的图像,以static/img

I'm trying to load an image from my project's local storage in email with Thymeleaf but it won't !

    <img src="../static/img/logo.png" alt="MyPicture" th:src="@{img/logo.png}">

although when I try with an absolute path it's perfectly loading

    <img src="C:/Workspace/myProject/src/main/resources/static/img/logo.png" alt="MyPicture">

My images are stored in static/img

project tree here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘过的浮云 2025-02-08 03:40:57

图像路径应以前向斜线为开始

<img alt="MyPicture" th:src="@{/img/logo.png}">

The image path shall start with a forward slash like

<img alt="MyPicture" th:src="@{/img/logo.png}">
So尛奶瓶 2025-02-08 03:40:57

尝试更改您的路径

<img src="img/logo.png" alt="MyPicture">

,您可能还希望从IDE设置中的缓存无效以检测到图像

try changing your path to

<img src="img/logo.png" alt="MyPicture">

and you might also want to invalidate cache from your IDE settings for the image to be detected

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文