我将 Thymeleaf 用于 Web 应用程序的模板。
当我创建链接时,我使用这样的 URL:
<img class="info"
src="../../../resources/img/image.png"
th:src="@{/resources/img/image.png}" />
如何在 Thymeleaf 中配置基本 URL?
我需要它,因为我的应用程序在当前 URL 中运行:
http://localhost:8080/myapp
它工作正常,但随后它重定向到:
http://www.myapp.com/
然后图像被搜索到:
http://www.myapp.com/myapp/resources/img/image.png
代替:
http://www.myapp.com/resources/img/image.png
我想要这样的东西:
<property name="baseURL" value="http://www.myapp.com"/>
最佳答案
尝试 Server-relative URLs :
<img class="info" th:src="@{~/resources/img/image.png}" />
更新
实际链接到 url part of Thymeleaf 2.1. tutorial
关于html - 如何在 Thymeleaf 中配置基本 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18651119/