优点:模板即原型,前后端分离。
缺点:效率不是最好的,甚至算差的。
引入依赖,在pom.xml文件添加以下内容。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在application.yml的配置文件里加入以下内容
thymeleaf:
cache: false # 关闭页面缓存
encoding: UTF-8 # 模板编码
prefix: classpath:/templates/ # 页面映射路径
suffix: .html # 构建URL时附加到查看名称的后缀
mode: HTML5 # 模板模式
cache属性默认值是true,把他设置为false,便于我们进行调试,不必每次修改都重启一遍项目。
encoding属性是模板编码
prefix属性是页面映射路径
suffix属性是构建URL时附加到查看名称的后缀
mode属性是模板模式