A, pom.xml introduced
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Two, application.properties increase related configuration
# Develop close cached, or can not see the live page
spring.thymeleaf.cache = false
spring.thymeleaf.mode HTML5 =
# Prefix
spring.thymeleaf.prefix = the CLASSPATH: / Templates /
# coding
spring.thymeleaf.encoding = UTF- 8
# type
spring.thymeleaf.content-type = text / HTML
# name suffix
spring.thymeleaf.suffix = .html
Three, templates folder create a new html page
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Index</title> </head> <body> This is a index portal! </body> </html>
Fourth, create a new class, the new html page jump to top
package net.Eleven.demo.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller // Note that do not use RestController annotation @ RequestMapping ( "/ Thymeleaf" ) public class ThymeleafController { @RequestMapping ( "Hello" ) public Object Hello () { return "index"; // no suffix, are arranged in the configuration file which increases } }