springboot的thymeleaf模板与freemarker模板的基础用法
1、springboot之thymeleaf模板
优点:最明显的优点就是它是html页面。下面直接上代码
使用thymeleaf首先要给他导入相关pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
注意:Spring Boot官方文档建议在开发时将缓存关闭,那就在application.properties文件中加入下面这行
spring.thymeleaf.cache=false
正式环境还是要将缓存开启的
下面是我写的一个demo,主要是介绍它的基础用法
<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>用户列表</title>
</head>
<body>
<h1 th:text="${title}">默认值</h1>
<table border="1px">
<thead>
<tr>
<td>