(五)、thymeleaf语法
(四)、thymeleaf前后端分离,th:text="${hello}" 是将div里边的文本内容设置为${hello},若不写th:text直接访问html,显示“这是div文本内容”,从而达到前后端分离的目的。
<div th:text="${hello}">这是div文本内容</div>
(三)使用thymeleaf,导入thymeleaf命名空间
xmlns:th="http://www.thymeleaf.org"
(二)thymeleaf官网查看其使用语法,导入其pdf到自己本地,方便随时看
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.pdf
一、springboot万事依赖均starts,故thymeleaf的依赖为springboot 官网中的starts中可以查询到
导入spring-boot-starter-thymeleaf依赖即可。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
@ConfigurationProperties(prefix = "spring.thymeleaf")
public class ThymeleafProperties {
private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;
public static final String DEFAULT_PREFIX = "classpath:/templates/";
public static final String DEFAULT_SUFFIX = ".html";