在 thymeleaf 中包含 html 页面 [英] Include html page in thymeleaf
问题描述
我有 2 个 HTML 文件,假设 one.html 和 two.html.在 one.html 中我想包含 two.html.
在 JSF 中,我可以这样做:
这意味着在 one.xhtml 文件中,我可以包含 two.xhtml.
我们如何在 *.html 文件中做到这一点?在百里香中
您可以轻松完成.你能分享你的 header.html
文件吗?
或者,让我表现得有点像我为我的项目所做的
在 header.html
旁边的 放一个代码:
<p>这是给客户的</p><div th:fragment="admin_header"><p>这是给管理员的</p>
假设您想将 client_header
添加到 index.html
中.请在您的 index.html
页面(在 内)
注意:::
之前的includes/header
指的是html路径(不包括.html
)和client_header
::
后引用 header.html
中您要插入的部分.
我希望你能理解我在这里解释的一切.
I have 2 HTML files, suppose one.html and two.html. In one.html I want to include two.html.
In JSF I can do it like that:
It means that inside one.xhtml file, I can include two.xhtml.
How can we do it in *.html file? in thymeleaf
you can do it easily. could you share your header.html
file?
or, let me show a bit like I do for my projects
in header.html
put in side the <body>
a code:
<div th:fragment="client_header">
<p>This is for client</p>
</div>
<div th:fragment="admin_header">
<p>This is for admin</p>
</div>
and let's say you want to add client_header
into the index.html
. Do follow these in your index.html
page (inside <body>
)
<div th:replace="includes/header :: client_header">
</div>
note: includes/header
before ::
refers the html path (excludes .html
) and client_header
after ::
refers the part in header.html
you want to insert.
I hope you understand everything that I have explain here.
这篇关于在 thymeleaf 中包含 html 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!