我已将以下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;
}
答案 0 :(得分:0)