1、导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2、写控制器代码(也可以用@Configuration)
package com.stick.core.page.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class PageController {
@RequestMapping("/person")
public String toPerson(){
return "person/index";
}
@RequestMapping("/stick")
public String toStick(){
return "stick/index";
}
}
3、index.html放入templates中,css和js文件放入public中(这两个文件夹自己创建就行)
4、通过不同路由成功访问不同页面