thymeleaf使用

 

(五)、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中可以查询到

https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/html/using-spring-boot.html#using-boot-starter

导入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";
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值