pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
作用:
充當視圖解析器角色,渲染視圖
Controller:
@Controller
public class IndexController {
@RequestMapping("/index")
public String index() {
return "index";
}
}
作用:
返回字符串提供視圖解析器中的視圖名稱
springboot加載html默認到resources/templates裏面尋找;創建index.html;
訪問地址: