th:action 定义后台控制器路径,类似<form>标签的action属性。

<form id="login-form" th:action="@{/login}">...</form>
th:each          对象遍历,功能类似jstl中的<c:forEach>标签。
<form id="login-form" th:action="@{/addStudent}"  th:object="${stuReqBean}" method="POST">
<div class="student" th:each="stuIter,rowStat:${stuReqBean.students}">
<input type="text" class="firstName" value="" th:field="*{students[__${rowStat.index}__].firstName}"/>
...
</div></form>
上面的例子中通过选择表达式*{}既能将表单绑定到后台的StudentRequestBean中的集合属性students,也能将Servlet上下文中的StudentRequestBean中的List类型的students变量回显,回显时通过th:each进行遍历。
注意1:绑定集合属性元素下标的用法*{students[__${rowStat.index}__].firstName}
注意2:如果List<Student> students为null,页面将无法显示表单,后台必须给students初始化一个值
注意3:stuIter代表students的迭代器
th:field          常用于表单字段绑定。通常与th:object一起使用。 属性绑定、集合绑定。
<form id="login-form" th:action="@{/login}" th:object="${loginBean}">...
<input type="text" value="" th:field="*{username}"></input>
<input type="text" value="" th:field="*{user[0].username}"></input>
</form>
th:href           定义超链接,类似<a>标签的href 属性。value形式为@{/logout}
<a th:href="@{/logout}" class="signOut"></a>
th:id              div id声明,类似html标签中的id属性。
<div class="student" th:id = "stu+(${rowStat.index}+1)"></div>
th:if        条件判断。
<div th:if="${rowStat.index} == 0">... do something ...</div>
th:fragment   我们可以使用th:fragment属性来定义一个模板,声明定义该属性的div为模板片段,常用与头文件、页尾文件的引入。常与th:include,th:replace一起使用。
例如:声明模板片段/WEBINF/templates/footer. html
<div th: fragment=" copy" >
2011 The Good Thymes Virtual Grocery
</div>
引入模板片段
<div th: include=" /templates/footer : : copy" ></div>
<div th: replace=" /templates/footer : : copy" ></div>
th:include      加载模板的内容
见上
th:replace      替换当前标签为模板的中标签
见上
th:object 用于表单数据对象绑定,将表单绑定到后台controller的一个JavaBean参数。常与th:field一起使用进行表单数据绑定
<form id="login-form" th:action="@{/login}" th:object="${loginBean}">...</form>
th:src             用于外部资源引入,类似于<script>标签的src属性,常与@{}一起使用。
<script th:src="@{/resources/js/jquery/jquery.json-2.4.min.js}"
th:value  用于标签复制,类似<option>标签的value属性。
<option th:value="Adult">Adult</option>
<input  id="msg" type="hidden" th:value="${msg}" />
 th:remove 删除代码
  • all 删除当前标签和其内容和子标签
  • body 不删除当前标签,但是删除其内容和子标签
  • tag 删除当前标签,但不删除子标签
  • all-but-first 删除除第一个子标签外的其他子标签
  • none 啥也不干
<a href="/something" th:remove="${condition}? tag : none">Link text not to be removed</a>
<table> <tr th:remove="all"> <td>Mild Cinnamon</td> </tr> </table>
 

Thymeleaf的th的更多相关文章

  1. spring boot(四):thymeleaf使用详解

    在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thymeleaf的使用.thymeleaf 是新一代的模板引擎,在spring4. ...

  2. Thymeleaf

    1.在html顶部添加 <html xmlns:th="http://www.thymeleaf.org"> 2.url表达式 @{...} <link rel= ...

  3. Thymeleaf 模板的使用

    Thymeleaf是现代化服务器端的Java模板引擎,不同与JSP和FreeMarker,Thymeleaf的语法更加接近HTML,并且也有不错的扩展性.详细资料可以浏览官网.本文主要介绍Thymel ...

  4. vert.x学习(三),Web开发之Thymeleaf模板的使用

    在vert.x中使用Thymeleaf模板,需要引入vertx-web-templ-thymeleaf依赖.pom.xml文件如下 <?xml version="1.0" e ...

  5. 页面上使用 Thymeleaf 的内联js不当造成了 java.lang.StackOverflowError: null 问题

    由于在页面上内联js使用不当,从而在从 Controller 跳转到页面时发生了以下错误: java.lang.StackOverflowError: null at org.thymeleaf.ut ...

  6. Thymeleaf 与 Javascript

    在 javascript 代码中使用 Thymeleaf 模板引擎: <script th:inline="javascript"> $("#content& ...

  7. Thymeleaf+SpringMVC,如何从模板中获取数据

    Thymeleaf+SpringMVC,如何从模板中获取数据 在一个典型的SpringMVC应用中,带@Controller注解的类负责准备数据模型Map的数据和选择一个视图进行渲染.这个模型Map对 ...

  8. Thymeleaf+Spring整合

    前言 这个教程介绍了Thymeleaf与Spring框架的集成,特别是SpringMvc框架. 注意Thymeleaf支持同Spring框架的3.和4.版本的集成,但是这两个版本的支持是封装在thym ...

  9. thymeleaf常用标签

    1. th:checked ,th:selected标签<input type="radio" value="M" name="gender&q ...

  10. thymeleaf的常见用法

    1,th:属性名="",就可以直接修改控件的属性,比如 <input th:type="button" th:name="xinxin" ...

随机推荐

  1. day96:flask:flask-migrate&flask-session&蓝图Blueprint&蓝图的运行机制

    目录 1.flask-migrate 2.flask-session 3.蓝图:Blueprint 4.蓝图的运行机制 1.数据库迁移:flask-migrate 1.Flask的数据库迁移 在开发过 ...

  2. Comparator比较器

    Comparator比较器 简介 为什么写? comparator 是javase中的接口,位于java.util包下,该接口抽象度极高,有必要掌握该接口的使用 大多数文章告诉大家comparator ...

  3. react-hash-calendar,移动端日期时间选择插件

    按照惯例,先上效果图 vue 版本同款日历:https://github.com/TangSY/vue-hash-calendar react-hash-calendar 支持手势滑动操作 上下滑动 ...

  4. 迭代器原理gif

  5. 怎样安装Arch Linux以及Deepin桌面环境

    一.概述 Arch Linux 是一个轻量级的Linux发行版本,实际上,Arch Linux提供给用户很多选择,用户可以自定义自己的安装过程,不x像其他很多的Linux发行版本,安装过程甚至是一个只 ...

  6. 做IT需要掌握的电力基础知识

    电流 损耗 直流电的传输损耗大,所以不适合长距离传输, 交流电的传输损耗小,所以适合长距离传输, 使用 直流电电压稳定,无白躁声,故适於电子产品使用(例如电视机,收音机电脑等), 交流电要经过整流/开 ...

  7. Lsi卡和IB卡在CentOS中升级

    LSI 9271 步骤1:准备升级工具和固件包 rpm -ivh MegaCli-8.07.14-1.noarch.rpm [root@phegdata01 ~]# unzip 23-34-0-000 ...

  8. 删除list列表中的某一个元素的多种方法

    当我们在处理业务的时候,很多情况下数据都要进行一层层的过滤,最近需要给一个列表中去除不符合条件的元素, 本来觉着挺简单的,Google了下发现很多方法都是旧方法,根本不符合我的需求. 于是参考着网上的 ...

  9. DRAM三种刷新方式(转载)

    设DRAM中电容的电荷每2ms就会丢失,所以2ms内必须对其补充.补充电荷是按行来进行的,为了[全部]内存都能保住电荷,必须对[所有]的行都得补充. 假设刷新1行的时间为0.5μs(刷新时间是等于存取 ...

  10. 基于struts2的记住账号密码的登录设计

    一个简单的基于struts2的登录功能,实现的额外功能有记住账号密码,登录错误提示.这里写上我在设计时的思路流程,希望大家能给点建设性的意见,帮助我改善设计. 登录功能的制作,首先将jsp界面搭建出来 ...