例如:
第一个页面
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>form提交</title>
<script type="text/javascript" src="jquery-2.0.3.min.js"></script>
</head>
<body>
<form id="form1" th:action="@{user/}" } method="post">
id<input type="text" id="userId" name="userId"><br/>
<button οnclick="tijiao()">提交</button>
<a th:href="@{'/login'}">login</a>
</form>
<div th:fragment="copydiv1">
这是第一个层
</div>
<script>
</script>
</body>
</html>
第二个页面:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
这是login页面
<div th:include="form::copydiv1"></div>
</body>
</html>
需求:我想在第二个页面中引用第一个页面的<div>
1.在第一个页面你想要抽取的标签中使用 th:fragment="copydiv1" 上面代码标了印记
2.在第二个页面引用 th:include="form::copydiv1" 上面代码标了印记
其中 form 为第一个页面的名称 copydiv1为第一个页面抽取的层级的名称