- 引入模板
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
- 访问控制@Controller (注意:@RestContruller注解后,页面无法渲染,只能返回字符串)
@Controller
public class TestController {
@RequestMapping("/index")
public String index(){
return "welcome";
}
}
- 创建welcome.html
- 启动,访问localhost:8080/index