原文链接:http://www.waphnb.com/article/62
常规配置thymeleaf的使用方式
spring:
thymeleaf:
prefix: classpath:/templates/
servlet.content-type: text/html
suffix: .html
1、取消thymeleaf对html的强制格式校验
1.1 添加maven依赖
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>${nekohtml.version}</version>
</dependency>
配置文件改为如下方式
spring:
thymeleaf:
mode: LEGACYHTML5
prefix: classpath:/templates/
servlet.content-type: text/html
suffix: .html
2、将springboot的静态文件放在jar包外面的配置
spring.resources.static-locations=classpath:/static/ (常规配置)
spring.resources.static-locations=file:D:/tools/web/static/ (jar包外配置)
本文介绍如何调整Thymeleaf设置以放宽HTML格式限制,并展示如何在SpringBoot应用中同时管理包内与包外的静态资源,实现更灵活的部署策略。
21万+

被折叠的 条评论
为什么被折叠?



