####首先,引入maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
####修改application.yml,可能原来是application.properties
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
content-type: text/html
mode: HTML5
####编写Controller
@Controller
public class HelloController {
@RequestMapping(value = "/ysk",method = RequestMethod.GET)
public String myhello(Model model){
model.addAttribute("name","Y.S.K");
return "hello";
}
}
####编写view,因为springBoot默认是模板位置是templates/
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.