THYMELEAF配置说明

本文介绍了Spring Boot中Thymeleaf的配置,包括模板缓存、模板检查、Content-Type、视图解析、模板编码、前缀和后缀等关键设置,帮助理解如何定制Thymeleaf在应用中的行为。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

THYMELEAF (ThymeleafAutoConfiguration)

开启模板缓存(默认值: true )

spring.thymeleaf.cache=true

检查模板是否存在,然后再呈现

spring.thymeleaf.check-template=true

检查模板位置是否正确(默认值 :true )

spring.thymeleaf.check-template-location=true
#Content-Type 的值(默认值: text/html )
spring.thymeleaf.content-type=text/html

开启 MVC Thymeleaf 视图解析(默认值: true )

spring.thymeleaf.enabled=true

模板编码

spring.thymeleaf.encoding=UTF-8

要被排除在解析之外的视图名称列表,⽤逗号分隔

spring.thymeleaf.excluded-view-names=

要运⽤于模板之上的模板模式。另⻅ StandardTemplate-ModeHandlers( 默认值: HTML5)

spring.thymeleaf.mode=HTML5

在构建 URL 时添加到视图名称前的前缀(默认值: classpath:/templates/ )

spring.thymeleaf.prefix=classpath:/templates/

在构建 URL 时添加到视图名称后的后缀(默认值: .html )

spring.thymeleaf.suffix=.html

Thymeleaf 模板解析器在解析器链中的顺序,默认情况下,它排第⼀位,顺序从 1 开始,只有在定义了额外的 TemplateResolver Bean 时才需要设置这个属性。

spring.thymeleaf.template-resolver-order=

可解析的视图名称列表,⽤逗号分隔

spring.thymeleaf.view-names=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值