高级thymeleaf(组件嵌套)
1.组件嵌套
1.需要提取的组件加上 th:fragment="组件名"
<nav class="col-md-2 d-none d-md-block bg-light sidebar" th:fragment="sidebar"> ... </nav>
2.使用组件的地方加上 th:replace="~{组件地址::组件名}"
<div th:replace="~{dashboard::sidebar}"></div>
2.thymeleaf是一个是一个动态语言,可以在语句中嵌套表达式
在class中添加if
<a th:class="${active=='list.html'?'nav-link active':'nav-link'}" th:href="@{/emps}"> 员工管理 </a>
....
分类:
springBoot
, 前端
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术