thymeleaf学习之各种学习过的绑定


title: thymeleaf学习2
date: 2019-11-22

原本在个人博客上写了一些博文,现转移到CSDN上

thymeleaf学习之各种学习过的绑定

在上一篇博客中,简单的介绍了thymeleaf的如何利用fragment作为模板,在网页需要的地方,嵌入模板网页中写的指定的部分。本文就将我目前涉及到的thymeleaf绑定简单罗列一下

  • th-text
    文字替换,将此处的文字替换为绑定的值
    例如:
<span th:text="${item.name}"></span>
  • th-utext
    在网页中写文字,相当于
<div></div>

中间写文字
例如:

<div th:utext="${info.themename}" style="font-size: 24px;color:#444"></div>
  • th:src
    thymeleaf的链接
    例如:
 <img th:src="'/static/img/icon/default.png'"
                                             class="round_icon" style="width:40px;height: 40px;float:left;">
  • th:href
    thymeleaf的超链接
    例如:
 <a th:href="'/user/'+${info.creator_oid}"><h4 th:text="${info.creator_name}">Tom Marvolo Riddle</h4></a>
  • th:each
    循环执行,类似于vue中的v-for
<div th:each="modelClass,index:${modelClassInfos}">

其中,${modelClassInfos}为绑定的model值,index类似于数组中的计数,0、1、2…等,modelClass为数组的值,配合th:each将数组modelClassInfos的值循环取出。

  • th:id
    thymeleaf的id,一般用来设置id值

一个介绍thymeleaf的博客:
https://www.cnblogs.com/zjfjava/p/6893486.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值