首页 文章

Thymeleaf布局不起作用

提问于
浏览
0

我有这样的布局:

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>


    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/main.css}"/>
<title layout:title-patern="$LAYOUT_TITLE - $CONTENT_TITLE">System</title>
</head>
<body>
    <th:block th:replace="fragments/header :: header"/>
    <div class="container">
        <th:block layout:fragment="content"/>
    </div>
    <th:block th:replace="fragments/footer :: footer"/>
</body>
</html>

我试图将它用于我的索引页面,如下所示:

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorate="~{fragments/layout}">
<head>
<title>Index</title>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
    <h1> Please login</h1>

    <ul>
        <li>Click here <a href="/user" th:href="@{/user}">to login</a>
        </li>
    </ul>

</div>
</body>
</html>

但它只是不起作用,索引页面不使用bootstrap和css文件,页脚和 Headers 也不使用 . 我使用百里香 - 布局 - 方言2.2.2我错过了什么?

1 回答

  • 0

    通过添加解决它

    <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
    

    到我的属性下的pom.xml文件

相关问题