gpt4 book ai didi

css - thymeleaf + CSS + SpringBoot

转载 作者:技术小花猫 更新时间:2023-10-29 10:18:37 26 4
gpt4 key购买 nike

我对 CSS 和 Thymeleaf 有疑问。

在我的 Spring Boot 应用程序中,我有这样的结构:

  • src/main/resource/static/css(用于 css 文件)
  • src/main/resource/static/templates(用于 html 文件)

现在,我的 html 页面名为 ErrorPage,css 文件名为 Layout.css,使用 Thymeleaf,在 ErrorPage 的头部:

<link href="../css/Layout.css" th:href="@{css/Layout.css}" type="text/css" />

但这行不通。

我做错了什么?

最佳答案

将您的 template 文件夹移到 resources 下:

  • src/main/resource/static/css(用于 CSS 文件);
  • src/main/resource/templates(用于 HTML 模板)。

然后更正link标签如下:

<link href="../static/css/Layout.css" th:href="@{/css/Layout.css}" rel="stylesheet" />

关于css - thymeleaf + CSS + SpringBoot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41586841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com