首先說明,不需要在此處做任何配置:
1、引入thmeleaf模板引擎
<!-- thmeleaf模板引擎 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2、配置application.properties 如下:
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.prefix=classpath:/templates/views/ #該路徑自己指定
spring.thymeleaf.suffix=.html
3、html頁面放到resources/templates下(可以自己在下面創建包,但要在prefix中指定,或者在controller中配置)
* idea創建的html頁面,<meta>標簽不是閉合的,需要添加</meta>,感覺thmeleaf太死板,容錯率太低
4、controller中如下:
OK,到這里啟動springboot就可以了