java - 布局:装饰不起作用 - Spring Boot
问题描述
我有一个带有 thymeleaf 的 Java Spring Boot 项目。我尝试在很多网络示例中使用 layout:decorate wihout 成功。最后一个是:
index.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{Layout}">
<head>
<title>Content page 1</title>
<script src="content-script.js"></script>
</head>
<body>
<section layout:fragment="content">
<p>This is a paragraph from content page 1</p>
</section>
<footer>
<p layout:fragment="custom-footer">This is some footer content from content page 1</p>
</footer>
<a th:href="@{/Layout}">Teste</a>
</body>
</html>
布局.html:
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<title>Layout page</title>
<script src="common-script.js"></script>
</head>
<body>
<header>
<h1>My website</h1>
</header>
<section layout:fragment="content">
<p>Page content goes here</p>
</section>
<footer>
<p>My footer</p>
<p layout:fragment="custom-footer">Custom footer here</p>
</footer>
</body>
</html>
pom.xml 父级:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
pom.xml 属性:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>8</java.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
</properties>
我不知道发生了什么:(
谢谢!
解决方案
推荐阅读
- android - Recyclerview 适配器中的 getItemViewType 方法无法正常工作
- c# - 当文本框没有输入值时,C# 输入字符串的格式不正确
- php - laravel 中的策略总是未经授权的
- android - 如何根据从另一个项目定义的角半径剪辑图层列表中的项目
- microservices - SEDA v/s SAGA 模式
- android - 如何更改 Android Spinner 视图元素上的文本
- python-3.x - 如何根据参考列表在数据框中的列中重命名输入错误的学生姓名
- python-3.x - Python(Windows)中父子进程之间的持续通信?
- android - 使用来自 json 源的数组适配器填充可搜索微调器
- hasura - hasura 是否生成索引?