1、引入thymeleaf依赖

 <!--thymeleaf-->
 <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
 </dependency>

2、在application.yml进行thymeleaf配置

# 配置页面地址
spring:   
  thymeleaf:   prefix: classpath:/templates/

3、编写Controller

// 服务启动自动跳转首页
@RequestMapping(value = {"/","index"})
public String index(){
  return "index";
}

 

文件结构:

SpringBoot 结合 Thymeleaf 进行页面的跳转

访问localhost:8080   或者 localhost:8080/index

SpringBoot 结合 Thymeleaf 进行页面的跳转

 

相关文章:

  • 2022-03-02
  • 2021-06-27
  • 2022-01-05
  • 2021-05-22
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2021-05-04
  • 2021-09-20
  • 2021-06-13
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案