⒈定义片段

  1.使用th:fragment   

     <div th:fragment="copy">
&copy; 2019 <a href="http://www.coreqi.cn">Coreqi</a>
</div>

  2.不使用th:fragment 

     <div id="copy-section">
&copy; 2019 <a href="http://www.coreqi.cn">Coreqi</a>
</div>

⒉引用片段

  1.引用使用th:fragment的片段

     <div th:insert="~{footer :: copy}"></div>

  2.引用不使用th:fragment的片段

     <div th:insert="~{footer :: #copy-section}"></div>

⒊引用模板使用的th:insert、th:replace、th:include三者之间的区别

  • th:insert  将简单地插入指定的片段作为正文的主标签
  • th:replace      用指定实际片段来替换其主标签
  • th:include        类似于th:insert,但不是插入片段,而是只插入此片段的内容(3.x版本后不再推荐使用)

Thymeleaf模板布局的更多相关文章

  1. thymeleaf 模板布局

    八.模板布局(Template Layout) 8.1 包含模板片段(Including template fragments) 定义和引用片段 我们通常想要从别的模板文件中调用一些模板片段,例如 页 ...

  2. Thymeleaf 模板布局三种区别

  3. Thymeleaf 模板

    Thymeleaf 模板布局 th:fragment.th:replace.th:insert.th:remove th:fragment  模板布局 模板片段说明 模板中,经常希望从其他模板中包含⼀ ...

  4. Springboot 使用thymeleaf模板layout布局

    使用layout布局前应该在pom文件中导入thymeleaf(dialect)依赖:如下 <properties> <project.build.sourceEncoding> ...

  5. (八)Thymeleaf的 th:* 属性之—— 模板布局& th:with& 属性优先级

    3.7 模板布局 模板名称:layout.html 3.7.1 th:fragment e.g.模板名为footer.html页面body部分如下: <body> <div th:f ...

  6. Thymeleaf模板的使用

    使用模板的要点:     页面主体结构固定,具体参数可变,尽可能让参数动态化,才能提高模板的复用性 ================================================== ...

  7. thymeleaf模板的使用(转)

    作者:纯洁的微笑 出处:http://www.ityouknow.com/ 在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thym ...

  8. Java 前端模板引擎学习:thymeleaf 模板引擎

    模板引擎接口 ITemplateEngine 一.后台数据与外部数据 1.处理后台数据 $表达式是个变量表达式,用于处理在  request parameters and the request, s ...

  9. 4.3 thymeleaf模板引擎的使用

    参考说明:以下笔记参考来自尚硅谷springboot教学中的笔记! thymeleaf官网docs: https://www.thymeleaf.org/documentation.html 模板引擎 ...

随机推荐

  1. smarty缓存

    huancun.php代码 <?php$p =1;if( !empty($_GET["page"])){ $p =$_GET["page"];}$file ...

  2. opencv源码学习: getGaussianKernel( 高斯核);

    参考: https://blog.csdn.net/u012633319/article/details/80921023 二维高斯核, 可以根据下面的公式推到为两个一维高斯核的乘积: 原型: /** ...

  3. docker的使用 -- windows

    1. 下载docker desktop https://www.docker.com/products/docker-desktop 更多操作指令 ps: 值得注意的是,刚下载下来的docker只能在 ...

  4. Thymeleaf中的&&解析问题

    1.问题: 最近使用了新的html模板thymeleaf..在模板里使用js语法时遇到问题,&&不能正确的被解析,使用if(a&&b){}可以通过模板解析,但是浏览器上 ...

  5. Linux记录-salt命令

    salt '*id*'  test.ping salt -N  组名  cmd.run '' salt -G "ipv4:0.0.0.0"  cmd.run '' salt '*i ...

  6. Ruby on rails 项目启动流程

    众所周知,我们可以通过rails s 这个命令来启动一个rails 项目,但是这条命令都干了哪些事呢?抽时间研究了下,同时感谢tomwang1013的博客.当我们输入rails s 这个命令的时候,项 ...

  7. thymeleaf 基础

    (一)Thymeleaf 是个什么?      简单说, Thymeleaf 是一个跟 Velocity.FreeMarker 类似的模板引擎,它可以完全替代 JSP .相较与其他的模板引擎,它有如下 ...

  8. ubuntu常用

    一.查看分区磁盘的速度命令 $ hdparm -Tt /dev/sda1 在终端打印出如下信息: /dev/sda1: Timing cached reads: MB in 2.00 seconds ...

  9. vue中slot插槽

    插槽就是vue实现的一套内容分发的API,将插槽元素作为承载分发内容的出口. 也就是说在组件模板中默认占用一个位置,当使用组件标签时候,组件标签的内容就会自动替换掉内容 slot中可以设置一些默认的内 ...

  10. 23.Secondary Index

    一. Secondary Index(二级索引)1.1. Secondary Index 介绍 • Clustered Index(聚集索引) ◦ 叶子节点存储所有记录(all row data) • ...