thymeleaf中的th:with用法

局部变量,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>
时间: 2024-07-31 23:25:42

thymeleaf中的th:with用法的相关文章

thymeleaf中的th:remove用法

一.删除模板片段使用th:remove属性 th:remove的值如下: 1.all:删除包含标签和所有的孩子. 2.body:不包含标记删除,但删除其所有的孩子. 3.tag:包含标记的删除,但不删除它的孩子. 4.all-but-first:删除所有包含标签的孩子,除了第一个. 5.none:什么也不做.这个值是有用的动态评估. <table> <tr> <th>NAME</th> <th>PRICE</th> <th>

thymeleaf中的th:assert用法

th:assert 断言标签 th:assert属性可以指定一个以逗号分隔的表达式对其进行评估并生产适用于每一个评价,如果不抛出异常 <div th:assert="${onevar},(${twovar} != 43)">...</div> 这方便验证参数的一个片断签名 <header th:fragment="contentheader(title)" th:assert="${!#strings.isEmpty(titl

IOS中NSString的常见用法

iOS NSString的常用用法 //1.创建常量字符串. NSString *astring = @"This is a String!"; //2.创建空字符串,给予赋值. NSString *astring = [[NSString alloc] init]; astring = @"This is a String!"; //3.在以上方法中,提升速度:initWithString方法 NSString *astring = [[NSString allo

thymeleaf中的日期格式化

本篇介绍些thymeleaf中的日期格式化的方法: 1.用#dates.format来解决: <span th:text="${#dates.format(user.date, 'yyyy-MM-dd')}">4564546</span> 或者<span th:text="${#dates.format(billingForm.startTime,'yyyy-MM-dd HH:mm:ss')}">4564546</span&

STL中的Vector相关用法

STL中的Vector相关用法 标准库vector类型使用需要的头文件:#include <vector>. vector 是一个类模板,不是一种数据类型,vector<int>是一种数据类型. Vector的存储空间是连续的,list不是连续存储的. 1. 定义和初始化 vector< typeName > v1; //默认v1为空,故下面的赋值是错误的v1[0]=5;//v2是v1的一个副本,若v1.size()>v2.size()则赋值后v2.size()被

MongoDB官方C#驱动中查询条件Query用法

http://www.cnblogs.com/viprx/archive/2012/09/06/2673693.html MongoDB条件查询的基本语法. Query.All("name", "a", "b");//通过多个元素来匹配数组  Query.And(Query.EQ("name", "a"), Query.EQ("title", "t"));//同时满足

awk中split函数的用法

The awk function split(s,a,sep) splits a string s into an awk array a using the delimiter sep. time=12:34:56 echo $time | awk '{split($0,a,":" ); print a[1]}' 12   echo $time | awk '{split($0,a,":" ); print a[3]}' 34   echo $time | awk

Linux中yum和apt-get用法及区别

Linux中yum和apt-get用法及区别 一般来说著名的linux系统基本上分两大类: 1.RedHat系列:Redhat.Centos.Fedora等 2.Debian系列:Debian.Ubuntu等 RedHat 系列 1 常见的安装包格式 rpm包,安装rpm包的命令是"rpm -参数" 2 包管理工具  yum 3 支持tar包 Debian系列 1 常见的安装包格式 deb包,安装deb包的命令是"dpkg -参数" 2 包管理工具 apt-get

C++中cin.clear()的用法

我们谈谈cin.clear的作用,第一次看到这东西,很多人以为就是清空cin里面的数据流,而实际上却与此相差很远,首先我们看看以下代码: #include <iostream>  using namespace std;  int main()   {              int a;              cin>>a;              cout<<cin.rdstate()<<endl;              if(cin.rds