首页 > 其他 > 详细

Thymeleaf模板基本配置

时间:2020-06-29 19:37:29      阅读:67      评论:0      收藏:0      [点我收藏+]

首先 在Spring Boot项目中使用Thymeleaf模板,首先必须保证引入Thymeleaf依赖,示例代码如下:

```html

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

```

其次,在全局配置文件中配置Thymeleaf模板的一些参数。一般Web项目都会使用下列配置,示例代码如:

```properties

spring.thymeleaf.cache = true #启用模板缓存

spring.thymeleaf.encoding = UTF-8 #模板编码

spring.thymeleaf.mode = HTML5 #应用于模板的模板模式

spring.thymeleaf.prefix = classpath:/templates/ #指定模板页面存放路径

spring.thymeleaf.suffix = .html #指定模板页面名称的后缀

```

? 上述配置中,spring.thymeleaf.cache表示是否开启Thymeleaf模板缓存,默认为true,在开发过程中通常会关闭缓存,保证项目调试过程中数据能够及时响应;spring.thymeleaf.prefix指定了Thymeleaf模板页面的存放路径,默认为classpath:/templates/;spring.thymeleaf.suffix指定了Thymeleaf模板页面的名称后缀,默认为.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

学习让人快乐,学习更让人觉得无知!学了1个多月的《Java工程师高薪训练营》,才发现自己对每个技术点的认知都很肤浅,根本深不下去,立个Flag:每天坚持学习一小时,一周回答网上3个技术问题,把自己知道都分享出来。

Thymeleaf模板基本配置

原文:https://www.cnblogs.com/lagoujiaoyu/p/13209878.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!