码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot 结合 Thymeleaf 进行页面的跳转

时间:2018-11-22 10:41:51      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:host   访问   inf   oca   页面   文件   ref   启动   服务启动   

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";
}

 

文件结构:

技术分享图片

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

技术分享图片

 

SpringBoot 结合 Thymeleaf 进行页面的跳转

标签:host   访问   inf   oca   页面   文件   ref   启动   服务启动   

原文地址:https://www.cnblogs.com/it-noob/p/9999350.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!