SpringThymeleaf文档
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SpringThymeleaf⽂档1.引⼊CSS
<link rel="stylesheet" th:href="@{/css的相对路径.css}">
2.引⼊JS
<script th:src="@{/js的相对路径.js}"></script>
3.放⾏资源⽂件
@Override
public void init(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/plugins/**");
web.ignoring().antMatchers("/css/**");
web.ignoring().antMatchers("/js/**");
web.ignoring().antMatchers("/img/**");
super.init(web);
}
4.表单的Action这样写
<form th:action="@{/login}" method="post">
5.⽚段
<div th:fragment="⽚段名称">
代码⽚断放在/src/main/resources/templates/fragments⽬录下
写代码⽚断
<!DOCTYPE html>
<html xmlns:th="">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<head th:fragment="common_header(title,links)">
<title th:replace="${title}">The awesome application</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" th:href="@{/plugins/fontawesome-free/css/all.min.css}">
<link rel="stylesheet" href="https:///ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" th:href="@{/css/adminlte.min.css}">
<th:block th:replace="${links}" />
</head>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div data-th-fragment="js">
<script th:src="@{/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script> <script th:src="@{/js/adminlte.min.js}"></script>
<script th:src="@{/js/demo.js}"></script>
</div>
</body>
</html>
引⽤⽚断
<head th:replace="fragments/head :: common_header(~{::title},~{})">
<title>添加Hello</title>
</head>
<div th:replace="fragments/js :: js">...</div>。