1、webjars
引入依赖
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.6.0</version>
</dependency>
输入
http://localhost:8080/webjars/jquery/3.6.0/jquery.js
可以访问到js代码。
2、public,static /**(resources根目录下) ,resources
localhost:8080访问
优先级:resources>static(默认)>public
3、 Thymeleaf
<!-- Thymeleaf-->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="all"
href="../../css/gtvg.css" th:href="@{/css/gtvg.css}">
<title>Title</title>
</head>
<body>
<div th:text="${msg}"></div>
<tr>
<h3 th:each="user:${users}" th:text="${user}"></h3>
<!-- <h3 th:each="user:${users}">[[${user}]]</h3>-->
</body>
</html>