thymeleaf常用标签

1. th:checked ,th:selected标签
<input type="radio" value="M" name="gender" th:checked="${data.gender}==‘M‘"/>男
<input type="radio" value="F" name="gender" th:checked="${data.gender}==‘F‘"/>女
<option th:selected="${cookie[draftStatus]}?${cookie[draftStatus].getValue()}==‘WSH‘:false">未审核</option>

2. 日期格式化,字符串截取
<span th:text="${#calendars.format(customerInfoVO.gmtCreated,‘yyyy-MM-dd HH mm‘)}"></span>
<span th:text="${#strings.substring(entity.contactTime,0,10)}"></span>
tempo 写法 <span>{{gmtCreate | date ‘YYYY-MM-DD HH:mm‘}} </span>

3. a 标签带参数
<a th:if="(${entity.draftStatus}==‘审核不通过‘) or (${entity.draftStatus}==‘已发布‘) " class="btn btn-info" th:href="@{getItemById?(id=${entity.id},draftStatus=${entity.draftStatus}) }">编辑</a>
th:href="@{/index/bannerList}" 加‘/’ url 取相对路径 (http://localhost:8081/bauna)

4.th:attr
th:attr="itemId=‘DQR‘+${entity.id},‘src‘=${entity.itemImg}"

5.列表序号 从1开始
<th:block th:each="entity,itemStat : ${contactNotes.getContactNotes()}">
<tr class="alignCenter entryOrderRow">
<td th:text="${itemStat.count+((page.curPage-1)*page.pageSize)}"></td>
<td th:text="${#calendars.format(entity.gmtCreate,‘yyyy-MM-dd‘)}"></td>
</tr>
</th:block>

6.判断条件 表达式
<span th:if="1==1"></span> thymeleaf
{% if changeAmountTimes == 0 %} tempo模板
1111
{% else %}
22222
{% endif %}

7. 三元表达式
<td th:text="${entity.contactTimeNext!=null?(#strings.substring(entity.contactTimeNext,0,10)):‘ ‘}"></td>

8.tempo 渲染
<tr data-template-for="userRoleOrgList">
<td colspan="2">部门:<span>{{orgName}}</span></td>
<td colspan="10">角色:<span>{{roleDescription}}</span></td>
</tr>
userRoleOrgList为user 对象属性时 循环userRoleOrgList

9.字符串处理
${#strings.length(entity.content)} 获取字符串长度
${#strings.substring(entity.content,0,20)} 截取

10.页面数据供js 调用
<script th:inline="javascript">
/*<![CDATA[*/
var goodsList = [[${goodsList}]];
/*]]>*/
</script>

11.th:class, th:classappend, th:colspan
<tr th:classappend="(${entity.isContact}==‘Y‘)?a:b" class="row-body alignCenter">
如果${entity.isContact}==‘Y‘ tr 采用样式a , 否则 用样式 b
<td th:colspan="${orderEntity.invoiceStatus}!=null?2:3"></td>

12.转义标签 th:utext
<span style="color:#41a1d2;" >2016-06-17 16:43</span>
tempo 转义 :Tempo.prepare(‘orderTempo‘,{‘escape‘: false})

13.工具类
日期处理 ${#dates.format(date,‘dd/MMM/yyyy HH:mm‘)}
${#calendars.format(cal,‘dd/MMM/yyyy HH:mm‘)}
数字 ${#numbers.formatInteger(1000000,3,‘COMMA‘)}
字符串 ${#strings.contains(name,‘EZ‘)}
$(#strings.substring(name,3,5))
集合 ${#arrays.length(array)}
${#lists.size(list)}

时间: 2024-08-06 03:38:24

thymeleaf常用标签的相关文章

关于Thymeleaf的常用标签以及ideaTools下找不到Test RESTful web service的解决办法

首先需要在html里加上如下代码开启thymeleaf标签库 <html lang="en" xmlns:th="http://www.thymeleaf.org"> lang="en"是html5需要的 常用表达式: ${...} 变量表达式 *{...} 选择表达式 #{...} 消息文字表达式 @{...} 链接url表达式 #maps 工具对象表达式 常用标签: th:action 定义后台控制器路径 th:each 循环语句

第2天:HTML常用标签

今天学完主要对所学知识点进行了整理. 一.超链接ahref:www.baidu.com(跳转页面):id名(锚点跳到相应div位置):01.rar(压缩包) target:_blank(新窗口打开):_self(当前窗口打开)二.文件路径绝对路径:(1)线上:线上绝对路径(2)线下:完整路径 相对路径:src=../img/bg.jpg(../是上一级目录) 三.HTML常用标签section :版块 用于划分页面上的不同区域,或者划分文章里不同的节 header :页面头部或者版块(secti

dede 首页的常用标签

dede 首页的常用标签!1.织梦标签学习方法1)不要深究织梦的标签是织梦的开发者提供给我们的,我们只要使用就好了,不要深究,这超出我们学习使用织梦的范畴了,我们本课程不是搞二次开发!2)复制很重要使用dede 不要去背那些提供给我们的标签,我们只要会复制粘贴,对某个标签有疑问直接粘贴到模板里看看能得到什么结果就可以了!2.标签分类1)单标签{dede:标签名属性="值" ..../}{dede:include filename="head.htm"/}2)双标签{

bootstrap_03_常用标签

<!doctype html> <html> <meta charset="utf-8" /> <head> <title>益司CMS-PC与手机建站集成</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no

HTML 常用标签

HTML常用标签 HTML的结构 <html> <head></head> <body></body> </html> Body标记的属性 <body 属性="属性值"> Background:给网页设置背景图片 bgColor:给网页设置背景颜色 文本与字体修饰标记 <b></b>或者<strong></strong> 给字体加粗 <i>&l

Jsp开发常用标签总结

Jsp开发常用标签总结 JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它[1]  是由Sun Microsystems公司倡导.许多公司参与一起建立的一种动态网页技术标准.JSP技术有点类似ASP技术,它是在传统的网页HTML(标准通用标记语言的子集)文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件,后缀名为(*.jsp). 用JSP开发的Web应用是跨平台的,

HTML基础—一般标签、常用标签和表格的应用

<html>    --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> <body> 页面显示的内容 </body> </html>    --结束标签 <!--注释内容--> 注释 body的属性: bgcolor                 页面背景色 text                    文字颜色(规定所有文本颜色) topmar

HTML基础(一)——一般标签、常用标签和表格

第一部分  HTML <html>    --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> <body> 页面显示的内容 </body> </html>    --结束标签 <!--注释内容--> 注释 body的属性: bgcolor                 页面背景色 text                    文字颜色(规定所有文

HTML常用标签(一)

HTML学习之HTML常用标签发布了,欢迎大家通过学编程吧xuebiancheng8.com来访问 HTML是WEB前端课程的基础,HTML是超文本标记语言的缩写,是制作网页的语言,是每个前端工程师必备的知识,在所有的编程语言中,HTML应该是比较简单的.学的快的同学学上几天就可以入门.HTML的应用场合比较广,目前不单单可以用在网页中,同样在手机里现在用的也比较多,使用html实现的代码,可以实现各种手机平台的适配,所以html的使用场合越来越广. HTML代码是由HTML标签组成的,比方说如