thymeleaf 个人常用标签
来源:互联网 发布:java 日志输出级别 编辑:程序博客网 时间:2024/05/29 19:34
th:text=”${}”//取文本值
th:href=”${}”//链接值
th:style=”${}”//css样式值
th:each迭代循环
iterStat称作状态变量,属性有: index:当前迭代对象的index(从0开始计算) count: 当前迭代对象的index(从1开始计算) size:被迭代对象的大小 current:当前迭代变量 even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算) first:布尔值,当前循环是否是第一个 last:布尔值,当前循环是否是最后一个引用自:[点击链接跳转](http://blog.csdn.net/sun_jy2011/article/details/40710429)<ol> <li>List循环: <table border="1"> <tr> <th>用户名</th> <th>邮箱</th> <th>管理员</th> <th>状态变量:index</th> <th>状态变量:count</th> <th>状态变量:size</th> <th>状态变量:current.userName</th> <th>状态变量:even</th> <th>状态变量:odd</th> <th>状态变量:first</th> <th>状态变量:last</th> </tr> <tr th:each="user,userStat : ${list}"> <td th:text="${user.userName}">Onions</td> <td th:text="${user.email}">test@test.com.cn</td> <td th:text="${user.isAdmin}">yes</td> <th th:text="${userStat.index}">状态变量:index</th> <th th:text="${userStat.count}">状态变量:count</th> <th th:text="${userStat.size}">状态变量:size</th> <th th:text="${userStat.current.userName}">状态变量:current</th> <th th:text="${userStat.even}">状态变量:even****</th> <th th:text="${userStat.odd}">状态变量:odd</th> <th th:text="${userStat.first}">状态变量:first</th> <th th:text="${userStat.last}">状态变量:last</th> </tr> </table> </li> <li>Map循环: <div th:each="mapS:${map}"> <div th:text="${mapS}"></div> </div> </li> <li>数组循环: <div th:each="arrayS:${arrays}"> <div th:text="${arrayS}"></div> </div> </li> </ol>
Thymeleaf提供了一个标签th:attr,可以把多个DOM标签用逗号分隔后写进去
第一种:<img src="../../images/gtvglogo.png" th:attr="src=@{/images/gtvglogo.png},title=#{logo},alt=#{logo}" /> 第二种:<img src="../../images/gtvglogo.png" th:src="@{/images/gtvglogo.png}" th:title="#{logo}" th:alt="#{logo}" />
attr写法
<form action="subscribe.html" th:action="@{/subscribe}"> <a href="product/list.html" th:href="@{/product/list}">Product List</a>
这里使用了th:action和th:href标签。
Thymeleaf还提供了两个合成标签:
th:alt-title th:lang-xmllang
同时这是两个标签比如:
<img src="../../images/gtvglogo.png" th:src="@{/images/gtvglogo.png}" <strong>th:alt-title</strong>="#{logo}" />
还有两个css标签
th:classappend th:styleappend<tr th:each="prod : ${prods}" class="row" th:classappend="${prodStat.odd}? 'odd'">
对于判断性的标签,比如checked
<input type="checkbox" name="option1" checked="checked" />
只能使用checked作为其值,即使使用true都不好使。Thymeleaf提供了这些标签的等价标签,值可以是判断语句,不为真会删除该标签:
比如:
<input type="checkbox" name="active" th:checked="${user.active}" />
参考文章:http://somefuture.iteye.com/blog/2253761
阅读全文
0 0
- thymeleaf 个人常用标签
- thymeleaf常用的一些标签属性
- thymeleaf常用的一些标签属性
- thymeleaf 标签
- thymeleaf标签
- thymeleaf标签整理
- thymeleaf自定义标签方言
- thymeleaf标签总结
- thymeleaf 常用用法
- Thymeleaf 常用属性
- Thymeleaf 常用属性
- Thymeleaf 常用属性
- Thymeleaf 常用属性
- thymeleaf模板整合shiro标签
- Thymeleaf 标签学习(一)
- Thymeleaf 标签学习(二)
- Thymeleaf 标签学习(三)
- thymeleaf中th标签整理
- The Tetris game wxPython
- 为什么说没有大数据的人工智能什么都不是?
- JSONString转List<map>;Duplicate key
- 今日小程序推荐:梵高的作品、吴昕的演技
- 运算符、流程控制
- thymeleaf 个人常用标签
- Mybatis Invalid bound statement (not found)的错误
- 安装oracle和sql deverloper的安装问题报错及解决方法
- 五、Json
- xml声明控件的时候,控件横向排列,width和height排列在一行
- 学习计划
- 搭建完全分布式redis集群
- 浅谈QNX进程间通信(IPC)
- slf4j + log4j使用