无法在thymeleaf中添加css文件

无法在thymeleaf中添加css文件,css,thymeleaf,Css,Thymeleaf,我是thymeleaf新手,尝试在thymeleaf中添加.css文件,但无法加载css文件。 我的css文件位于src/main/resources/templates/style.css中 <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>State 1 for Document</title> </head>

我是thymeleaf新手,尝试在thymeleaf中添加.css文件,但无法加载css文件。 我的css文件位于src/main/resources/templates/style.css中

 <!DOCTYPE html>
 <html xmlns:th="http://www.thymeleaf.org">

 <head>
 <title>State 1 for Document</title>
 </head>

 <div th:if="${InstaPanState==1 and InstaPanStateStatus==0}">
 <head lang="en">
    <title>Instaveritas PAN Verification</title>
    <link rel='stylesheet prefetch' 
   href='https://fonts.googleapis.com/css?family=Open+Sans:400,300' 
    th:href="@{https://fonts.googleapis.com/css?
    family=Open+Sans:400,300}"/>
    <link rel='stylesheet prefetch' 
     href='https://fonts.googleapis.com/css?family=Open+Sans:400,300' 
     th:href="@{https://fonts.googleapis.com/css?
     family=Open+Sans:400,300}" />
    <link type="text/css" rel="stylesheet" href="style.css"  
    th:href="@{/style.css}" media="all"/>
</head>

文件的状态1
Instaveritas PAN验证

您需要添加一个资源映射,请参见

您需要添加一个资源映射,请参见

您可以在资源下创建一个名为static的文件夹和一个名为css的子文件夹,并将您的css文件移动到那里,例如:
resources/static/css/style.css

那么就这样称呼它:

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

您可以在资源下创建一个名为static的文件夹和一个名为css的子文件夹,并将css文件移动到那里,例如:
resources/static/css/style.css

那么就这样称呼它:

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


你会想发布你的配置,并准确描述什么不起作用-你是否有任何例外,或者CSS只是没有出现在你的页面上?在生成的HTML上查看源代码并发布。只是css不出现你想发布你的配置并准确描述什么不起作用-你有没有发现任何异常,或者css不出现在你的页面上?在生成的HTML上查看源代码并发布。只是css不显示