【问题标题】:does not display css content through thymeleaf不通过 thymeleaf 显示 css 内容
【发布时间】:2019-02-20 03:59:13
【问题描述】:

我有 css 文件: main.css

h1 { 
    color: red;
}

index.html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Drink Shop</title>
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}"/>
</head>
<body>
    <h1>Wellcome</h1>
</body>
</html>

一切看起来都不错,但是h1文字的红色:wellcome没有出现 我用的是百里香,弹簧靴。 也许我应该在 pom.xml 中添加一些依赖?

层次结构

【问题讨论】:

  • 你能发布你的控制器代码吗?

标签: java html css thymeleaf


【解决方案1】:

试试这个,

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

【讨论】:

  • 尝试在上面的链接中添加/static/css
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 2012-10-27
  • 1970-01-01
  • 2017-11-12
  • 1970-01-01
  • 1970-01-01
  • 2021-04-12
相关资源
最近更新 更多