SpringBoot配置thymeleaf模板

springBoot默認支持的html模板是thymeleaf模板,既然官方都默認支持了,那麼我也就簡單學習了一下,在這裏記錄一下:

1. 引入對thymeleaf模板

直接在pom.xml中添加thymeleaf依賴:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2. thymeleaf常用配置

下面列舉一些thymelea模板一些常用的默認配置

#spring.thymeleaf.cache = true #啓用模板緩存,開發階段要使用false哦。
#spring.thymeleaf.check-template = true #在呈現模板之前檢查模板是否存在。
#spring.thymeleaf.check-template-location = true #檢查模板位置是否存在。
#spring.thymeleaf.content-type = text / html #Content-Type值。
#spring.thymeleaf.enabled = true #啓用MVC Thymeleaf視圖分辨率。
#spring.thymeleaf.encoding = UTF-8 #模板編碼。
#spring.thymeleaf.excluded-view-names = #應該從解決方案中排除的視圖名稱的逗號分隔列表。
#spring.thymeleaf.mode = HTML5 #應用於模板的模板模式。另請參見StandardTemplateModeHandlers。
#spring.thymeleaf.prefix = classpath:/ templates / #在構建URL時預先查看名稱的前綴。
#spring.thymeleaf.suffix = .html #構建URL時附加到查看名稱的後綴。
#spring.thymeleaf.template-resolver-order = #鏈中模板解析器的順序。
#spring.thymeleaf.view-names = #可以解析的視圖名稱的逗號分隔列表。/ templates / #在構建URL時先查看名稱的前綴。
#spring.thymeleaf.suffix = .html #構建URL時附加到查看名稱的後綴。
#spring.thymeleaf.template-resolver-order = #鏈中模板解析器的順序。
#spring.thymeleaf.view-names = #可以解析的視圖名稱的逗號分隔列表。/ templates / #在構建URL時先查看名稱的前綴。
#spring.thymeleaf.suffix = .html #構建URL時附加到查看名稱的後綴。
#spring.thymeleaf.template-resolver-order = #鏈中模板解析器的順序。
#spring.thymeleaf.view-names = #可以解析的視圖名稱的逗號分隔列表
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章