使用Spring Tool Suite版本的Thymeleaf模板中没有结束标记:3.8.4.RELEASE [英] No end tag in Thymeleaf template using Spring Tool Suite Version: 3.8.4.RELEASE

查看:148
本文介绍了使用Spring Tool Suite版本的Thymeleaf模板中没有结束标记:3.8.4.RELEASE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spring Initializr使用嵌入式Tomcat + Thymeleaf模板引擎生成了一个Spring Boot Web应用程序。
我有这个Thymeleaf模板

I've generated a Spring Boot web application using Spring Initializr, using embedded Tomcat + Thymeleaf template engine. I have this Thymeleaf template

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<body>

    <div th:fragment="common-navbar" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a th:text="#{navbar.home.text}" href="/"></a></li>
                    <li><a th:text="#{navbar.about.text}" href="/about"></a></li>
                    <li><a th:text="#{navbar.contact.text}" href="/contact"></a></li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li th:if="${#authorization.expression('!isAuthenticated()')}">
                        <a th:href="@{/login}" th:text="#{navbar.login.text}" />
                    </li>
                    <li th:if="${#authorization.expression('isAuthenticated()')}">
                        <form id="f" th:action="@{/logout}" method="post" role="form" class="navbar-form">
                            <button type="submit" th:text="#{navbar.logout.text}" class="btn btn-primary" />
                        </form>
                    </li>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </div>

</body>
</html>

但我有2个警告没有结束标记(< / a>) 。 &安培; 无结束标记(< / button>)

But I have 2 warnings No end tag (</a>). & No end tag (</button>).

推荐答案

如果你使用 spring-boot-starter-thymeleaf 依赖,你应该添加

If you use spring-boot-starter-thymeleaf dependency, you should add

<properties>
    <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>

到您的 pom.xml

这迫使maven使用Thymeleaf 3.默认的Thymeleaf 2不支持纯HTML5。

This forces maven to use Thymeleaf 3. The default Thymeleaf 2 doesn't support pure HTML5.

此处有更多信息: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html#howto-use-thymeleaf-3

这篇关于使用Spring Tool Suite版本的Thymeleaf模板中没有结束标记:3.8.4.RELEASE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆