码迷,mamicode.com
首页 > 其他好文 > 详细

thymeleaf中的th:with用法

时间:2014-10-17 15:16:58      阅读:1363      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   sp   div   on   log   bs   

局部变量,th:with能定义局部变量:

<div th:with="firstPer=${persons[0]}">
  <p>
    The name of the first person is <span th:text="${firstPer.name}">Julius Caesar</span>.
  </p>
</div>

当th:with被处理,firstPer变量创建一个局部变量和变量添加到map自上下文,以便它是用于评估和其他上下文中声明的变量从开始,但只有包含< div >标记的范围内。

div th:with="firstPer=${persons[0]},secondPer=${persons[1]}">
  <p>
    The name of the first person is <span th:text="${firstPer.name}">Julius Caesar</span>.
  </p>
  <p>
    But the name of the second person is 
    <span th:text="${secondPer.name}">Marcus Antonius</span>.
  </p>
</div>

th:width属性允许重用变量定义在相同的属性:

<div th:with="company=${user.company + ‘ Co.‘},account=${accounts[company]}">...</div>

 

thymeleaf中的th:with用法

标签:style   blog   color   ar   sp   div   on   log   bs   

原文地址:http://www.cnblogs.com/suncj/p/4031138.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!