一、项目结构

二、放置静态资源
将CSS、JS和Image 文件放在src/main/webapp/目录css,js,images下 。


在Thymeleaf模板中,可以使用Thymeleaf的URL表达式来引用这些静态资源。
html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="css/index.css"/>
<script src="js/index.js"></script>
<!-- URL表达式-->
<!-- <link rel="stylesheet" th:href="@{/css/index.css}"/>-->
</head>
<body>
欢迎页面!<p/>
<h1 th:text="${hello}">Hello</h1>
<button onclick="my1()">Click</button>
<a href="javascript:my2()"><img src="images/woman.jpeg" height="200px" width="200px"> </a>
<a href="javascript:my3()"><img th:src="@{/images/2.png}" height="200px" width="200px"> </a>
</body>
</html>
三、运行效果



