在 thymeleaf 中包含 html 页面

use*_*906 5 thymeleaf

我有 2 个 HTML 文件,假设 one.html 和 two.html。在 one.html 中我想包含 two.html。

在 JSF 中,我可以这样做:

这意味着在 one.xhtml 文件中,我可以包含 two.xhtml。

我们如何在 *.html 文件中做到这一点?在百里香叶

jua*_*umn 1

在 one.html 中,您可以按照以下步骤包含two.html:

  1. 将两个页面放在 resources 文件夹下,例如 /resources/one.html、/resources/two.html
  2. 通过在 one.html 中添加以下行,将 two.html 包含在 one.html 中: <div th:insert="two :: two"></div>

  3. 在two.html 中的标签后面添加这段代码<body><div th:fragment="two">

<div th:fragment="two">这应该包括由into one.html提交的代码位

百里香文档中的更多信息