1,首先在pom文件中引入模板引擎jar包
1<dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-thymeleaf</artifactId> 4</dependency> 5 62,在application.properties中配置模板引擎 7 8spring.thymeleaf.prefix=classpath:/templates/
3,在templates下建立login.html文件
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"/> 5 <title>Title</title> 6</head> 7<body> 8<h1>1314314141</h1> 9</body> 10</html>
4,写controller
1package com.example; 2 3import org.springframework.stereotype.Controller; 4import org.springframework.web.bind.annotation.RequestMapping; 5 6/** 7 * Created by hzm on 2017/4/1. 8 */ 9@Controller 10public class HelloController { 11 12 13 @RequestMapping("/test") 14 public String test(){ 15 return "login"; 16 } 17} 18 195输入网址 20 21http://localhost:8080/test 22 236页面会出现