Springboot+Thymeleaf中常用的th标签
记录一下。
关键字 功能介绍 案例
th:id 替换id <input th:id="'xxx' + ${collect.id}"/>
th:text 文本替换 <p th:text="${collect.description}">description</p>
th:utext 支持html的文本替换 <p th:utext="${htmlcontent}">conten</p>
th:object 替换对象 <div th:object="${session.user}">
th:value 属性赋值 <input th:value="${user.name}" />
th:with 变量赋值运算 <div th:with="isEven=${prodStat.count}%2==0"></div>
th:style 设置样式 th:style="'display:' + @{(${sitrue} ? 'none' : 'inline-block')} + ''"
th:onclick 点击事件 th:onclick="'getCollect()'"
th:each 属性赋值 tr th:each="user,userStat:${users}">
th:if 判断条件 <a th:if="${userId == collect.userId}" >
th:unless 和th:if判断相反 <a th:href="@{/login}" th:unless=${session.user != null}>Login</a>
th:href 链接地址 <a th:href="@{/login}" th:unless=${session.user != null}>Login</a> />
th:switch 多路选择 配合th:case 使用 <div th:switch="${user.role}">
th:case th:switch的一个分支 <p th:case="'admin'">User is an administrator</p>
th:fragment 布局标签,定义一个代码片段,方便其它地方引用 <div th:fragment="alert">
th:include 布局标签,替换内容到引入的文件 <head th:include="layout :: htmlhead" th:with="title='xx'"></head> />
th:replace 布局标签,替换整个标签到引入的文件 <div th:replace="fragments/header :: title"></div>
th:selected selected选择框 选中 th:selected="(${xxx.id} == ${configObj.dd})"
th:src 图片类地址引入 <img class="img-responsive" alt="App Logo" th:src="@{/img/logo.png}" />
th:inline 定义js脚本可以使用变量 <script type="text/javascript" th:inline="javascript">
th:action 表单提交的地址 <form action="subscribe.html" th:action="@{/subscribe}">
th:remove 删除某个属性 <tr th:remove="all"> 1.all:删除包含标签和所有的孩子。2.body:不包含标记删除,但删除其所有的孩子。3.tag:包含标记的删除,但不删除它的孩子。4.all-but-first:删除所有包含标签的孩子,除了第一个。5.none:什么也不做。这个值是有用的动态评估。
th:attr 设置标签属性,多个属性可以用逗号分隔 比如 th:attr="src=@{/image/aa.jpg},title=#{logo}",此标签不太优雅,一般用的比较少。
关键字 功能介绍 案例
th:id 替换id <input th:id="'xxx' + ${collect.id}"/>
th:text 文本替换 <p th:text="${collect.description}">description</p>
th:utext 支持html的文本替换 <p th:utext="${htmlcontent}">conten</p>
th:object 替换对象 <div th:object="${session.user}">
th:value 属性赋值 <input th:value="${user.name}" />
th:with 变量赋值运算 <div th:with="isEven=${prodStat.count}%2==0"></div>
th:style 设置样式 th:style="'display:' + @{(${sitrue} ? 'none' : 'inline-block')} + ''"
th:onclick 点击事件 th:οnclick="'getCollect()'"
th:each 属性赋值 tr th:each="user,userStat:${users}">
th:if 判断条件 <a th:if="${userId == collect.userId}" >
th:unless 和th:if判断相反 <a th:href="@{/login}" th:unless=${session.user != null}>Login</a>
th:href 链接地址 <a th:href="@{/login}" th:unless=${session.user != null}>Login</a> />
th:switch 多路选择 配合th:case 使用 <div th:switch="${user.role}">
th:case th:switch的一个分支 <p th:case="'admin'">User is an administrator</p>
th:fragment 布局标签,定义一个代码片段,方便其它地方引用 <div th:fragment="alert">
th:include 布局标签,替换内容到引入的文件 <head th:include="layout :: htmlhead" th:with="title='xx'"></head> />
th:replace 布局标签,替换整个标签到引入的文件 <div th:replace="fragments/header :: title"></div>
th:selected selected选择框 选中 th:selected="(${xxx.id} == ${configObj.dd})"
th:src 图片类地址引入 <img class="img-responsive" alt="App Logo" th:src="@{/img/logo.png}" />
th:inline 定义js脚本可以使用变量 <script type="text/javascript" th:inline="javascript">
th:action 表单提交的地址 <form action="subscribe.html" th:action="@{/subscribe}">
th:remove 删除某个属性 <tr th:remove="all">
1.all:删除包含标签和所有的孩子。
2.body:不包含标记删除,但删除其所有的孩子。
3.tag:包含标记的删除,但不删除它的孩子。
4.all-but-first:删除所有包含标签的孩子,除了第一个。
5.none:什么也不做。这个值是有用的动态评估。
th:attr 设置标签属性,多个属性可以用逗号分隔 比如 th:attr="src=@{/image/aa.jpg},title=#{logo}",此标签不太优雅,一般用的比较少。
Springboot+Thymeleaf中常用的th标签相关推荐
- JSP页面中常用四种标签
JSP页面常用四种标签: 1. EL表达式: ${} 2. jstl表达式(sun apache): <%@ taglib prefix="c" uri="htt ...
- dw常用标签_dreamweaver中常用到的标签及含义
maxlength=字元数> [6]预设checkbox或radio的初值 -- checked <input type=checkbox checked> <input ty ...
- pycharm项目中如何安装包_如何将Thymeleaf技术集成到SpringBoot项目中
给天气预报一个"面子" 截至目前,不仅有了天气预报的API接口,也有了数据的缓存方案.现在,就要进行天气预报服务的实现,也就是说,这里需要一个面向用户的应用.这个应用应该拥有友好的 ...
- SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍
SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍 本篇博文将介绍几种如何处理url中的参数的注解@PathVaribale/@Requ ...
- 帝国cms中常用标签/灵动标签/判断语句
帝国cms中常用标签(总结) 在帝国cms实际建站应用中,对首页.列表页.内容页这三个页面模板支持的变量是不同的.爱折腾的摄影大叔将帝国cms中常用标签/灵动标签/判断语句(帝国cms中常用标签总结归 ...
- 【HTML 教程系列第 11 篇】HTML 中常用的文本格式化标签
这是[HTML 教程系列第 11 篇],如果觉得有用的话,欢迎关注专栏. 在网页中,有时需要为文字设置粗体.斜体.下划线或上下标等效果,这时就需要用到 HTML 中的文本格式化标签(也叫文本标签),常 ...
- 【Echarts】ECharts中常用的标签
详细的标签详解 ECharts中常用的标签 ECharts中常用的标签 title标签 legend tooltip xAxis和yAxis 不同种类图的区别 ECharts中常用的标签 title标 ...
- Springboot+thymeleaf+IDEA——解决th标签的报错问题,爆红,找不到标签
文章目录 Springboot+thymeleaf+IDEA--解决th标签的报错问题,爆红,找不到标签 Springboot+thymeleaf+IDEA--解决th标签的报错问题,爆红,找不到标签 ...
- Spring Boot Thymeleaf中使用Shiro标签
在<Spring-Boot-shiro权限控制>中,当用户访问没有权限的资源时,我们采取的做法是跳转到403页面,但在实际项目中更为常见的做法是只显示当前用户拥有访问权限的资源链接.配合T ...
最新文章
- 异常:java.util.ConcurrentModificationException
- 英雄无敌3版的仙剑奇侠传
- js 如何实现bind
- fatal: unable to access ‘https://github.com/PanJiaChen/vue-element-admin.git/‘: OpenSSL SSL_read: Co
- 深度学习cnn人脸检测_用于对象检测的深度学习方法:解释了R-CNN
- 将DataTable的内容以EXCEl的形式导出到本地
- GB28181开放流媒体服务平台LiveGBS实际测试时问题排查
- 关于python import的sys.path路径问题
- simpledateformat格式_如何使用SimpleDateFormat?
- 《利用python进行数据分析》读书笔记--第五章 pandas入门
- Thinking in C++ ----第二章 对象的创建和使用
- 北斗广播星历和精密星历的下载
- 2018年腾讯校招产品群面体会
- 齐齐哈尔计算机应用软件学校,黑龙江齐齐哈尔计算机应用技术课程
- linux文件下生成一个文件,Linux系统下生成一个指定大小的文件要注意什么?
- 弘辽科技:淘宝电商创业的生存法则,你知道吗?
- antd a-input-number 的基本使用
- elasticsearch search timeout机制
- 树莓派家用NAS解决方案
- 百度网盘里的加密文件怎么看?