1,引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2,添加静态文件
3,修改配置文件:在application.properties中添加:
#静态资源整合
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ ,swagger-ui.html,druid/index.html #thymeleaf 模板配置 cache 缓存开发时该禁止
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
4,添加controller
package com.googosoft.controller.test; import java.util.Map; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class TestController { @RequestMapping("index")
public String index(Map<String,Object> params){
return "/index.html";
} @RequestMapping("log")
public String log(Map<String,Object> params){
return "/log.html";
} }
4,测试