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 ...
最新文章
- PHP 两个页面跳转,session会失效?
- Bitmap recycle()
- 教你玩转CSS Position(定位)
- 2 小时学会 springboot ( 附实例讲解 )
- java实验_Java实验报告(实验一)
- 源码包安装mysql5.7.25_centos源码安装mysql5.7.25-boost
- 如何评价周志华深度森林模型
- 背景图的属性(backgroud)
- 24期分期免息可以提前还吗?
- gerp命令基础介绍
- Java进阶:SpringMVC中通过监听器将Spring上下文对象放置到servletContext中,方便其他地方使用
- 技术人的充电时刻,200分钟QA交流,尽在SDCC 2017·深圳站
- 机器学习和深度学习有什么区别?
- php输出甲子年,甲子年是哪一年?甲子年生人今年多大?
- 常见损失函数 损失函数选择方法
- 【个人研究】21世纪西方运用脑电(EEG)的音乐研究动向分析(一)
- 2015年西安小升初奥数培训班奥数老师(排名排行)龙虎英雄榜
- 数据标注去哪接任务订单?靠谱的数据标注平台有哪些?
- 类的不同实例化使用一张虚函数表
- 你有一条微信未发送_微信支持发送大文件;男子薅90年爱奇艺VIP;京东方再次未通过苹果质量审查...