<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> * {font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;} .header {background-color: #f5f5f5;padding: 20px;} .header a {padding: 0 20px;} .container {padding: 20px;margin:20px auto;} .footer {height: 40px;background-color: #f5f5f5;border-top: 1px solid #ddd;padding: 20px;} </style> </head> <body> <header class="header"> <div> 测试接口Demo </div> </header> <div class="container" layout:fragment="content"></div> <footer class="footer"> <div> <p style="float: left">©Exfresh WMS</p> </div> </footer> </body> </html>
<html lang="zh-CN"前边我们提到的路径,这个就是你layout.html文件的位置.
xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="demolayout/layout1">
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>nz.net.ultraq.thymeleaf</groupId> <artifactId>thymeleaf-layout-dialect</artifactId> </dependency>
参考:https://www.jianshu.com/p/3b5ebc545a99
关于thymeleaf+layout布局的使用方式,spring boot 访问页面(静态页面及jsp页面)
原文:https://www.cnblogs.com/shy1766IT/p/9996765.html