th:replace th:include
原文:https://blog.csdn.net/h1021456873/article/details/79085505
Thymeleaf html 导入(th:replace & th:include)
模板模块导入
首先定义一个/WEBINF/templates/footer.html文件:
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"><body><div th:fragment="copy">© 2011 The Good Thymes Virtual Grocery</div></body>
</html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
上面的代码定义了一个片段称为copy,我们可以很容易地使用th:include 或者 th:replace属性包含在我们的主页上:
<body>
...
<div th:include="footer :: copy"></div>
</body>
- 1
- 2
- 3
- 4
include的表达式想当简洁。这里有三种写法:
- “templatename::domselector” 或者 “templatename::[domselector]”引入模板页面中的某个模块。
- “templatename”引入模板页面。
- “::domselector” 或者 “this::domselector” 引入自身模板的模块
上面所有的templatename和domselector的写法都支持表达式写法:
<div th:include="footer :: (${user.isAdmin}? #{footer.admin} : #{footer.normaluser})"></div>
- 1
不使用th:fragment来引用模块
...
<div id="copy-section">
© 2011 The Good Thymes Virtual Grocery
</div>
...
<body>
...
<div th:include="footer :: #copy-section"></div>
</body>
th:include 和 th:replace的区别
<footer th:fragment="copy">
© 2011 The Good Thymes Virtual Grocery
</footer>
<body>
...
<div th:include="footer :: copy"></div>
<div th:replace="footer :: copy"></div>
</body>
<body>
...
<div>
© 2011 The Good Thymes Virtual Grocery
</div>
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
</body>
th:replace th:include相关推荐
- boost::replace相关的测试程序
boost::replace相关的测试程序 实现功能 C++实现代码 实现功能 boost::replace相关的测试程序 C++实现代码 #include <boost/range/algor ...
- boost::mpl模块实现replace相关的测试程序
boost::mpl模块实现replace相关的测试程序 实现功能 C++实现代码 实现功能 boost::mpl模块实现replace相关的测试程序 C++实现代码 #include <boo ...
- boost::hana::replace用法的测试程序
boost::hana::replace用法的测试程序 实现功能 C++实现代码 实现功能 boost::hana::replace用法的测试程序 C++实现代码 #include <boost ...
- c++stl和std_std :: replace()函数以及C ++ STL中的示例
c++stl和std C ++ STL std :: replace()函数 (C++ STL std::replace() function) replace() function is a lib ...
- asp.net的cms 核心代码篇
好像开源有点多余,核心代码就下面这些. 1 using System;2 using System.Collections;3 using System.Collections.Generic;4 u ...
- [译]Vulkan教程(04)基础代码
[译]Vulkan教程(04)基础代码 General structure 通用结构 In the previous chapter you've created a Vulkan project w ...
- Thymeleaf 基本用法总结
一.引用命名空间 <html xmlns:th="http://www.thymeleaf.org"> 在html中引入此命名空间,可避免编辑器出现html验证错误,虽 ...
- boost使用学习总结
boost常用库案例 http://www.cnblogs.com/wangkangluo1/archive/2011/07/19/2110746.html 1.boost::any boost::a ...
- Thymeleaf抽取公共页面片段
抽取页面 项目中,一般把所有的公共页面片段都抽取出来 放在一个独立的页面中 其他,所有的页面根据需要进行引用 参考文档 th:fragment 抽取公共元素 Name,随便自定义命名 <!DOC ...
最新文章
- 在JavaScript中逐个遍历数组?
- powerdesigner使用vba脚本创建物理模型的表和列
- Cisco2620路由器的密码恢复和灾难性恢复
- 给部署在openshift上的WordPress添加wptouch插件
- Android手游《》斗地主完整的源代码(支持单机和网络对战)
- 树上倍增求LCA详解
- Repeater的使用
- [转载] python通过adb获取android手机耗电量
- 调色插件怎么安装_修图调色一键搞定!PS大师级调色插件NikCollection 八合一送你...
- Java基础---数组内容详解
- Python+pywin32批量转换Word文件为PDF文件
- activemq mysql 配置详解_activeMQ数据库配置
- 使用Infopath时要注意的有哪些
- 区块链技术指南:术语
- Linux部署-elasticsearch7.6.1
- 本学期关于Android学习的总结
- 富爸爸穷爸爸--读书笔记
- 题目 1902: 九宫格
- 2015年秋季腾讯校园招聘开发岗笔试题(四道大题)
- Thread线程中的stop方法过时问题
热门文章
- 微信App支付相关问题
- BLE中GATT介绍
- 浅谈html5的发展与现状摘要,浅谈HTML5的发展与现状(最标准格式论文)
- “蝙蝠”关系学(上):“蝙蝠”…
- 随机头像大全,多分类带历史记录微信小程序源码下载支持流量主
- 孙悟空,.NET和Web争霸
- Django实战技巧(2)-git代码仓分支管理技巧
- swagger python自动化用例_swagger 自动生成接口测试用例
- 如何让企业督办管理系统对接第三方应用
- slickedit字体设置——使用 Verdana 字体