springboot使用thymeleaf模版引擎步骤
- 在pom里加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
- templatesl里写html文件
- 在html里加入
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
4.controller测试
@Controller
public class DemoApplication {
@RequestMapping("/index")
public String hello(Model model) {
model.addAttribute("msg","hello springboot!");
return "index";
}
}
- html里显示
<span th:text="${msg}"></span>