pom中引入thymeleaf依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
配置application.properties
是让controller层到templates文件夹寻找xx.html(src/main/resources/templates)
spring.thymeleaf.prefix=classpath:/templates/
在templates下建立index.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Title</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
新建一个controller
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by kemp on 2018/8/15.
*/
@Controller
@RequestMapping("/sys")
public class MyController {
@RequestMapping("/test")
public String test(){
return "index";
}
}