java - 布局:装饰不能在百里香叶中解决
问题描述
我已将以下 html 标记添加到引用的文件中base.html
:
<html
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{base}"
>
但是,每当我调用它时,都会失败并出现以下错误:
[THYMELEAF][http-nio-8080-exec-5] Exception processing template "register":
An error happened during template parsing (template: "/Users/david/IdeaProjects/Greeting/src/main/resources/templates/register.html")
当我删除该行时,html 呈现正常,但显然没有导入 base.html 模板文件。这是我的项目结构:
- resources
- templates
- base.html
- register.html
最后,我在我的 WebConfig 中添加了这个:
private TemplateEngine templateEngine(ITemplateResolver templateResolver) {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver);
engine.addDialect(new LayoutDialect());
return engine;
}
解决方案
推荐阅读
- ios - 出现 EXC_CORPSE_NOTIFY 符号崩溃,错误时无法跟踪
- javascript - 使用 javascript 在表格中插入表单值
- python - 在 Google Cloude Engine 虚拟机上不活动后,tcp 连接滞后
- docker - 不能将另一个 python3 容器中的 postgres 容器与 psycopg2 一起使用
- javascript - 在 JS 表单中按下按钮时转到功能
- swiftui - 如何在 SwiftUI 中创建全局分数计数器变量
- google-earth-engine - 将 Shapefile 上传到 Google 地球引擎资产“错误:无效的属性名称:编号为。”
- linux - 在 Linux X86 中使用任务集在隔离 CPU 上运行进程的不同行为
- c# - 如何使用并行测试设置在 Selenium C# 和 SpecFlow 中关闭 Chrome 驱动程序并从内存中清除?
- swiftui - 如何使用正确的 onAppear 和 onDisappear 在 SwiftUI 中隐藏和取消隐藏视图并保持状态?