在spring boot和thymeleaf的整合中,需要以下几点注意和配置
- 首先要做的是需要的是引入thymeleaf框架的依赖包。在pom.xml 文件中引入需要的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
- 其次是在.properties文件或则在.xml文件中加入如下内容,
spring:
thymeleaf:
prefix:
classpath: /templates/
suffix: .html
mode: html
encoding: UTF-8
servlet:
content-type: text/html
开发时关闭缓存,不然没办法看到时实页面
cache: false
- 注意的是,想要看到返回的页面时,注意@RestController和@Controller的区别哦
- 可以看详细点击链接@RestController和@Controller的区别