spring - 如何在百里香中将一个html页面包含到另一个页面?
问题描述
我在 Spring Boot 应用程序中有以下项目结构 -
/templates/home/index.html
/templates/includes/header.html
我想在索引文件中包含头文件。我已经尝试了链接 - https://stackoverflow.com/questions/23538693/include-html-page-in-thymeleaf# =
但冒号 '::' 显示错误。
我是百里香的新手。谁能解释一下?谢谢。
解决方案
感谢所有试图帮助我的人。我解决了以下问题 -
//header.html
<div th:fragment="header">
<!-- related code of header file >
</div>
//index.html
//to include header follow the code( the header file is inside includes directory)
<div th:replace="/includes/header :: header"> </div>
推荐阅读
- ios - 点击推送通知:无法定向到特定的 ViewController
- javascript - JavaScript 画布 + requestAnimationFrame 口吃
- html - 如何使 2 张图像同时响应
- laravel - 将 Laravel mysql 迁移转换为 postgresql 时出现索引错误
- swift - '#selector' 的参数不引用 Swift 按钮目标中的 '@objc' 方法、属性或初始化程序
- css - 为什么 ThemeProvider (Material UI) 在这里对我不起作用?
- laravel - 一般错误:1364 字段“学生 ID”没有默认值
- configuration - Sublime Text 3 中的 set_layout 设置
- c# - AutoCAD C#/.Net:公开实体坐标
- git - 分支落后于 'GitHub/master' 1 次提交