一、引入maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
二、默认配置
默认模板位置为:classpath:/templates/
默认后缀名为:.html
三、通过控制器跳转到页面
@Controller
public class TableController {
@Autowired
UserService userService;
@GetMapping("/dynamic_table.html")
public String dynamicTable(Model model, @RequestParam(required = false,defaultValue = "1") int pn){
Page<User> page = userService.getByDesc(pn);
model.addAttribute("users",page);
return "table/dynamic_table";
}
}
四、页面设置
五、通过themleaf语法基本使用themleaf