thymeleaf 设置不校验html标签

教程分享 > Java教程 > Thymeleaf (2940) 2024-08-06 15:11:05

thymeleaf 设置不校验html标签

默认配置下,thymeleaf对.html的内容要求很严格,比如,如果少封闭符号/,就会报错而转到错误页。也比如你在使用Vue.js这样的库,然后有<div v-cloak></div>这样的html代码,也会被thymeleaf认为不符合要求而抛出错误。

通过设置thymeleaf模板可以解决这个问题,下面是具体的配置:

spring.thymeleaf.cache=false
​​​​​​​spring.thymeleaf.mode=LEGACYHTML5

LEGACYHTML5需要搭配一个额外的库NekoHTML才可用 项目中使用的构建工具是Maven添加如下的依赖即可完成:

<dependency>
  <groupId>net.sourceforge.nekohtml</groupId>

  <artifactId>nekohtml</artifactId>

  <version>1.9.22</version>

</dependency>
https://www.leftso.com/article/370.html

相关文章
Thymeleaf 递归,Thymeleaf模板引擎递归展示如评论留言等场合适用
thymeleaf 设置不校验html标签
SSH/SSM项目中如何集成thymeleaf?本文将讲解SSH/SSM项目中如何集成thymeleaf模板引擎
使用thymeleaf 模板创建时间 使用thymeleaf 创建指定日期为:2023-10-18 #dates.create(2023,10,18) 使用thymeleaf ...
本文说一下在thymeleaf模板引擎中,如何给 textarea 赋值
thymeleaf模板 报错信息:​​​​​​​org.thymeleaf.exceptions.TemplateInputException: Error resolving template...
环境Thymeleaf 3.0循环5次需求:输出5个li编码参考:&lt;ul&gtl; &lt;li th:each="index:${#numbers.sequence(1,
springboot 使用thymeleaf 模板引擎中url中的&引起的org.xml.sax.SAXParseException: 对实体 "uid" 的引用必须以 ';' 分隔符结尾。问题解决
设置数据源将数据写入到 Model 中 @RequestMapping("/menulist") public String MenuManagerList(M
配置在resources目录下面创建i18n目录,然后创建几个文件messages.properties 默认显示语言内容messages_en_US.prop