zoukankan      html  css  js  c++  java
  • Thymeleaf 中如何实现including

    Problem:Jsp中有including,Thymeleaf中有无类似的语法?

    Solution:有,Themeleaf中提供同样功能的标签是 th:fragment="blockName" 和  th:replace="fileName::blockName"

    Steps:

    1.在共通网页common.html中定义通用块:

        <!-- 标题栏 -->
        <div class="navbar"  th:fragment="topNavbar">
            <div class="navbar-inner">
                <ul class="nav pull-right"></ul>
                <a class="brand" href="index.html"><span class="first">A股</span>
                    <span class="second">Master</span></a>
            </div>
        </div>

    2.在功能网页中引入通用块:

        <!-- 标题栏 -->
        <div class="navbar"  th:replace="common::topNavbar"></div>

    实现了这两个步骤后,标题栏在common.html中书写和维护就行了,其它页面无需变更用就行了。

    --2020年5月3日--

  • 相关阅读:
    codevs1288 埃及分数
    codevs1792 分解质因数
    dp
    JAVA大数贪心
    求最长不重叠子串
    初识后缀数组
    dp
    两数相除,判断小数位是否有限位
    构造二分图匹配
    建立多个树状数组
  • 原文地址:https://www.cnblogs.com/heyang78/p/12820753.html
Copyright © 2011-2022 走看看