Thymeleaf + CSS + SpringBoot [英] Thymeleaf + CSS+SpringBoot

查看:101
本文介绍了Thymeleaf + CSS + SpringBoot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对CSS和Thymeleaf有问题.

I have a problem with CSS and Thymeleaf.

在我的Spring启动应用程序中,我具有以下结构:

In my Spring boot app, I have this structure:

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

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

Now, with my html page named ErrorPage and css file named Layout.css, using Thymeleaf I have, in the head of 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模板).
  • src/main/resource/static/css (for CSS files);
  • src/main/resource/templates (for HTML templates).

然后按如下所示纠正link标记:

Then correct the link tag as follows:

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

这篇关于Thymeleaf + CSS + SpringBoot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆