1.Layout文件:layout.html
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head ></head>
<body>
111
<div layout:fragment="content"></div>
222
</body>
</html>
2. 子页面
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<meta charset="utf-8" />
<title>首页</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div layout:fragment="content" style="width:96%;margin-left:auto;margin-right:auto;">
<div style="font-size:18px;">
测试thymeleaf layout布局 模式套用
js css 全部继承自layout
content 因页面不同而不同
</div>
</div>
</body>
</html>
网友评论