zoukankan      html  css  js  c++  java
  • thymeleaf标签必须由匹配的结束标记终止

    问题描述

    springboot使用Thymeleaf标签时会报元素类型必须由匹配的结果标记终止。 
    如下所示 

    如果我们一个个的给这些元素后面加上终止标记也是件很麻烦的事~~~~

    解决办法

    方法一: 
    在pom.xml中的 properties 中指明Thymeleaf标签的版本号即可

    <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <!--添加如下两行代码指定Thymeleaf标签的版本-->
            <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
            <thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
        </properties>

    但是我表示这是一个坑,因为我在pom.xml中加了这两行代码,导致了我使用springsecurity的<sec:authorize>标签时总是标签不起作用,后来通过两天的时间才找出是这里为以后的程序埋下了一个深深的坑啊!!!

    于是才有了下面的方法二·······

    方法二:
    在pom.xml中添加依赖

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.22</version>
    </dependency>
    

      application.properties中

    spring.thymeleaf.mode=LEGACYHTML5

    springboot2.0以后没有这样的问题

  • 相关阅读:
    poj3372 Candy Distribution
    poj3270 Cow Sorting
    poj2888 Magic Bracelet
    poj2429 GCD & LCM Inverse
    poj1811 Prime Test
    poj2689 Prime Distance
    【思维】2017多校训练七 HDU6121 Build a tree
    【字符串+BFS】Problem 7. James Bond
    【dfs】codeforces Journey
    【思维+贪心】codeforces Game of the Rows
  • 原文地址:https://www.cnblogs.com/zengpeng/p/10248405.html
Copyright © 2011-2022 走看看