thymeleaf引入js/css无效的解决办法
我在学习springboot的时候有一次用thymeleaf引入js/css,怎么都不行,报500错误,,在翻了很多博客尝试了很久之后终于解决了这个bug,在此记录下来
- 在pom中添加依赖:
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
- 在build中添加:
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
- 在index.html中添加:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
- 还是无法解决的话再添加: type=“text/css”
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" type="text/css">
之后就能完美的解决啦!