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. Linux中的基本命令无法使用,报Command not found的错误的解决方法

    一般我们在Linux中执行命令的时候,会报 Command not found 的错误,报这种错误一般有两种原因:一是你的系统中没有安装这个命令,需要你手动安装,另外一种原因就是平常这些命令用着好好的 ...

  2. appium每次运行不初始化

    最近测试公司软件遇到一个问题,每次运行Appium测试代码,打开软件都是初始化,每次的新手教程以及无法记住密码一堆问题,导致效率很低,而且定位有时候出问题. 先看初始化的代码 1 from appiu ...

  3. JQuery案例:左右选

    左右选 <head> <meta charset="UTF-8"> <title></title> <style> se ...

  4. 由OptionalLong想到的拆装箱问题

    包装类型为null的时候时候拆箱会报空指针

  5. 【鸿蒙开发板试用报告】用OLED板实现FlappyBird小游戏(中)

    小伙伴们久等了,在上一篇<[开发板试用报告]用OLED板实现FlappyBird小游戏(上)>中,我们本着拿来主义的原则,成功的让小鸟在OLED屏幕上自由飞翔起来,下面我们将加入按钮交互功 ...

  6. 关于深度学习之中Batch Size的一点理解(待更新)

    batch 概念:训练时候一批一批的进行正向推导和反向传播.一批计算一次loss mini batch:不去计算这个batch下所有的iter,仅计算一部分iter的loss平均值代替所有的. 以下来 ...

  7. docker安装myInfluxDB映射本地目录+开机后台自启动

    CentOS7环境 1.docker hup库搜索influxdb docker search influxdb 2.拉取influxdb镜像 docker pull influxdb 3.查看已下载 ...

  8. 这些鲜为人知的前端冷知识,你都GET了吗?

    背景 最近公司项目不多,比较清闲,划水摸鱼混迹于各大技术博客平台,瞬间又GET了好多前端技能,一些属于技巧,一些则是闻所未闻的冷知识,一时间还消化不过来,不由的发出一声感叹! 前端可真是博大精深 于是 ...

  9. 小bug小坑总结

    1. 小程序canvas那些原生组件的层级默认是最高的,而且不能更改,平常的div弹框什么的上面就会显示出原生组件的内容, 解决办法:cover-view,cover-image,button 2. ...

  10. PyQt(Python+Qt)学习随笔:print标准输出sys.stdout以及stderr重定向QTextBrowser等图形界面对象

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 <在Python实现print标准输出sys.stdout.st ...