does not display css content through thymeleaf

3829 views java
-3

i have css files: 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>

everything looks good, but the red color of h1 text: wellcome does not show up I using thymeleaf, spring boot. Maybe I should add some dependence in pom.xml?

hierarchy

enter image description here

answered question

Can you post your Controller code?

1 Answer

6

Try this one,

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

posted this

Have an answer?

JD

Please login first before posting an answer.

Ads

Categories