当我在我的thymeleaf html电子邮件模板中引用images/Yellow.svg时,我得到了500个错误。我得到的错误如下:
出现了意外错误(type=Internal服务器错误,status=500)。链接基"img/Yellow.svg“不能是上下文相对(/)或页面相对,除非您实现org.thymeleaf.context.IWebContext接口(上下文属于类: org.thymeleaf.context.Context) (./模板/创建帐户-电子邮件:49)
下面是引用图像的代码:
<img id="right-logo" src="../static/img/Yellow.svg" th:src="@{img/Yellow.svg}" alt="yellow logo"/>我试着做了下面的事情,但对我来说没有用。
<img id="right-liberty-logo" src="../static/img/Yellow.svg" th:src="@{~img/Yellow.svg}" alt="yellow liberty logo"/>```发布于 2019-04-23 15:52:35
我下载了thymeleaf示例项目(宠物诊所)并将pets.png映像更改为我添加到项目中的svg文件:
src
└─── main
└─── webapp
└─── resources
└─── images
└─── test.svg一切都很好。在显示此图像的文件welcome.html中,文件路径设置如下:<img src="../../resources/images/test.svg" th:src="@{/resources/images/test.svg}" />路径welcome.html为:
src
└─── main
└─── webapp
└─── WEB-INF
└─── thymeleaf
└─── welcome.html确保正确设置了src和th:src属性。
https://stackoverflow.com/questions/55812887
复制相似问题