• springboot2 +thymeleaf


    springboot 1.5. 9+ thymeleaf  

    <!--sidebar-->
    <nav class="col-md-2 d-none d-md-block bg-light sidebar" th:fragment="sidebar">
        <div class="sidebar-sticky">
            <ul class="nav flex-column">
    
                <li class="nav-item">
    
                    <a class="nav-link active"
                        th:class="${activeUri=='main'?'nav-link active':'nav-link'}"
                        href="#" th:href="@{/main}">
                        <span data-feather="home"></span>
                        Dashboard <span class="sr-only">(current)</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="file"></span>
                        Orders
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="shopping-cart"></span>
                        Products
                    </a>
                </li>
    
                <li class="nav-item">
    
                    <a class="nav-link active" href="#" th:href="@{/emps}"
                       th:class="${activeUri=='emps'?'nav-link active':'nav-link'}">
                        <span data-feather="users"></span>
                        员工管理
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="bar-chart-2"></span>
                        Reports
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="layers"></span>
                        Integrations
                    </a>
                </li>
            </ul>
    
            <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
                <span>Saved reports</span>
                <a class="d-flex align-items-center text-muted" href="#">
                    <span data-feather="plus-circle"></span>
                </a>
            </h6>
            <ul class="nav flex-column mb-2">
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="file-text"></span>
                        Current month
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="file-text"></span>
                        Last quarter
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="file-text"></span>
                        Social engagement
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">
                        <span data-feather="file-text"></span>
                        Year-end sale
                    </a>
                </li>
            </ul>
        </div>
    </nav>

    在另一个页面引用的时候,传递参数

        <div th:replace="commons/bar::#sidebar(activeUri='emps')"></div>

    在springboot 2+ thymeleaf 的时候引用就要使用

     <div th:replace="commons/bar :: sidebar('activeUri'='emps')"></div>

    在参数上也要加上引号,踩坑

  • 相关阅读:
    ADB 操作手机的粘贴板
    JSESSIONID的简单说明
    Android无线调试出现错误的解决方法
    adb shell input text 完美支持中文输入
    SQL Server 2022来了
    新技能GET!在前端表格中花式使用异步函数的奥义
    地表最强IDE ——Visual Studio 2022正式发布
    用前端表格技术构建医疗SaaS 解决方案
    JavaScript Sanitizer API:原生WEB安全API出现啦
    突破技术限制,实现Web端静默打印
  • 原文地址:https://www.cnblogs.com/zwb1234/p/9201266.html
Copyright © 2020-2023  润新知