【问题标题】:How to include one html page to another in thymeleaf?如何在百里香中将一个html页面包含到另一个页面?
【发布时间】:2018-06-10 10:26:54
【问题描述】:

我在 Spring Boot 应用程序中有以下项目结构 -

/templates/home/index.html

/templates/includes/header.html

我想在索引文件中包含头文件。 我已经尝试了链接 - https://stackoverflow.com/questions/23538693/include-html-page-in-thymeleaf#=

但是冒号 '::' 显示错误。

我是百里香的新手。谁能解释一下? 谢谢。

【问题讨论】:

  • 请添加 index.html 和准确的错误堆栈跟踪
  • 谢谢。我解决了这个问题。代码如下 - ` //header.html

标签: spring spring-mvc spring-boot thymeleaf


【解决方案1】:

感谢所有试图帮助我的人。 我解决了以下问题 -

//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>

【讨论】:

    【解决方案2】:

    你可以轻松做到。你能分享你的“header.html”文件吗?

    或者,让我展示一下我为我的项目所做的一些事情

    在'header.html'中放入a代码:

    这是给客户的

    这是给管理员的

    假设您想将“client_header”添加到“index.html”中。请在您的“index.html”页面(内部)中遵循这些

    注意:'::'之前的'includes/header'指的是html路径(不包括'.html'),'::'之后的'client_header'指的是'header.html'中要插入的部分。

    我希望你能理解我在这里解释的一切。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      • 2011-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多