比方说,我有两个Thymeleaf的模板:在不包含片段定义元素的情况下使用Thymeleaf模板?
的index.html:
<!DOCTYPE html>
<html>
<head></head>
<body>
<header>foo</header>
<section>
<div th:replace="fragments/main :: content"></div>
</section>
<footer>bar</footer>
</body>
</html>
片段/ main.html中:
<!DOCTYPE html>
<html>
<head></head>
<body>
<div th:fragment="content">
<p>This is the main content.</p>
</div>
</body>
</html>
我如何防止Tymeleaf从包括div
定义合成输出中的片段?也就是说,如何获取Thymleaf生成以下的输出:
<!DOCTYPE html>
<html>
<head></head>
<body>
<header>foo</header>
<section>
<p>This is the main content.</p>
</section>
<footer>bar</footer>
</body>
</html>
相反的:
<!DOCTYPE html>
<html>
<head></head>
<body>
<header>foo</header>
<section>
<div>
<p>This is the main content.</p>
</div>
</section>
<footer>bar</footer>
</body>
</html>
美丽。谢谢。我会尽快接受它。 –