gpt4 book ai didi

java - 使用装饰器的 Thymeleaf 布局不起作用

转载 作者:行者123 更新时间:2023-11-30 05:22:05 32 4
gpt4 key购买 nike

我正在开发一个使用最新版本的 spring boot 和 thymeleaf 的应用程序,我想使用 thymeleaf 的布局功能我的布局在页面layout.html上,其他页面在index.html

\src\main\resources\templates\layout.html

<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
...

\src\main\resources\templates\index.html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
layout:decorate="~{layout.html}">

在导航器中,我有同样的事情,就好像 thymeleaf 没有替换layout.html

最佳答案

需要使用layout:fragment来替换内容。引用示例https://www.thymeleaf.org/doc/articles/layouts.html

关于java - 使用装饰器的 Thymeleaf 布局不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59375569/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com