!
也想出现在这里? 联系我们
广告位
当前位置:首页>开发>其他开发实例>springboot使用thymeleaf模板引擎配置layout

springboot使用thymeleaf模板引擎配置layout

1.目录结构

springboot使用thymeleaf模板引擎配置layout

2.layout.html代码

<html lang="en" xmlns:th="http://www.thymeleaf.org">

<!-- head-通用CSS -->
<head th:fragment="header(title)">
    <meta charset="UTF-8">
    <title th:text="${title}"></title>
    <link rel="stylesheet" th:href="@{/static/pc/css/reset.css}">
</head>

<!-- 通用JS -->
<div th:fragment="script">
<script src="https://www.zxlmx.com/static/js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
</div>

3.home.html代码

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="~{'pc/common/layout' :: header('首页')}"/>
</head>
<body>
<div>
    首页
</div>

<th:block th:include="~{'pc/common/layout' :: script}"/>
</body>
</html>

4.编译后结果

springboot使用thymeleaf模板引擎配置layout

给TA打赏
共{{data.count}}人
人已打赏
其他开发实例

使用go get安装github依赖不成功的解决方法

2022-10-8 20:41:44

其他开发实例

spring boot 热更新,热部署

2022-10-9 20:40:50

声明 本站上的部份代码及教程来源于互联网,仅供网友学习交流,若您喜欢本文可附上原文链接随意转载。无意侵害您的权益,请发送邮件至 [email protected] 或点击右侧 私信:林沐阳 反馈,我们将尽快处理。
{{yiyan[0].hitokoto}}
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索