Thymeleaf:Sprint Boot 从 1.4.3 升级到 1.5.22 后,index.html 页面无法正确显示

问题描述 投票:0回答:1

最近,我开始尝试使用 Thymeleaf 升级 SpringBoot 中的一个应用程序(从 1.4.3 到 1.5.22)。应用程序启动正常,但是当我检查这些 html 页面时,它们都没有正确显示。查看更多详细信息后,我发现index.html 中缺少一些内容。

以下显示了 Thymeleaf 转换后两个版本的 index.html 部分。

链接 rel="icon" th:href="@{/static/console/img/favicon.ico}" type="image/x-icon"

查看1.4.3版本源码页面 链接 rel="icon" type="image/x-icon" href="/dev/static/console/img/favicon-e58edb9fec1d2c653aac22892a890626.ico"

查看1.5.22版本中的源代码页面 链接 rel="icon" type="image/x-icon" href="/static/console/img/favicon.ico"

href和src属性好像少了后缀jsession id。谁能知道我需要做什么来纠正这个问题?

spring-boot thymeleaf spring-thymeleaf
1个回答
0
投票

当图标位于

src/main/resources/static/console/img
中时,请在 Thymeleaf 模板中使用以下内容:
th:href="@{/console/img/favicon.ico}"

(因此,如果您从 Thymeleaf 引用它,则

static
不应出现在路径中。)

© www.soinside.com 2019 - 2024. All rights reserved.