春天启动百里香叶布局方言不起作用



>我刚刚创建了一个新的Spring Boot v1.5项目,并面临百里香叶布局方言不起作用的问题。

我的 build.gradle 及其在类路径上有依赖项。

compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '2.1.2'

我有以下布局文件

    <!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">
<head>
    <meta charset="UTF-8" />
    <title>Default Template</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="" />
    <meta name="description" content="" />
    <meta name="title" content="" />
    <link rel="stylesheet" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>
<body>
    <!-- header -->
    <header th:include="shared/nav-menu :: menu-admin" />
    <!-- page content -->
    <th:block>
        <section layout:fragment="content"></section>
    </th:block>
</body>
</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:decorator="default">
<head>
    <title>Parameter Manager</title>
</head>
<body>
    <section layout:fragment="content">
        <h2>OMG I am on the page!</h2>
    </section>
</body>
</html>

HTML 输出是内容.html文件。它没有按预期工作。标题和导航菜单应该是 HTML 输出的一部分。此外,在页面源代码中,情况不应该如此。

显然最新版本的 Thymeleaf 布局方言不适用于 Spring Boot 1.5。使用版本 1.2.9,它可以按预期工作。

compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '1.2.9'

最新更新