<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
spring:
thymeleaf:
prefix: classpath:/templates/
@Controller
@RequestMapping("/view")
public class PageController {

@GetMapping("/link")
public String page() {
return "link";
}
}

在templates目录下创建html文件

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>test</h1>
</body>
</html>

SpringBoot访问html_html


​http://localhost/view/link​

SpringBoot访问html_html_02