相关疑难解决方法(0)

Thymeleaf + CSS + SpringBoot

我有CSS和Thymeleaf的问题.

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

  • 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" />
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

我究竟做错了什么?

css3 thymeleaf spring-boot

16
推荐指数
1
解决办法
3万
查看次数

如何将css和js添加到spring启动应用程序中?

我尝试使用Thymeleaf在Spring Boot中将CSS添加到我的HTML页面,在静态文件夹中添加CSS文件并以这种方式链接:

<link rel="stylesheet" th:href="@{/css/home.css}" href="../../css/home.css" />
Run Code Online (Sandbox Code Playgroud)

但它不起作用.


我想停止访问URL中的CSS和js,所以我将此方法添加到我的安全配置中:

@Override
public void configure(WebSecurity web) throws Exception {
   web
      .ignoring()
      .antMatchers("/resources/static/**"); // #3
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我什么是我的错误或是否需要任何配置?

spring thymeleaf spring-boot

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

spring-boot ×2

thymeleaf ×2

css3 ×1

spring ×1