thymeleaf小记

@的使用

<link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet">

@要注意加不加“/”的区别


if的使用

<div th:if="${fileUrl eq '${fileUrl}'}">${fileUrl}</div>

<img th:if="${fileUrl eq '${fileUrl}'}" th:src="${fileUrl}" class="img-responsive"/>



1、遍历:

we will use th:each in our template to iterate the list of products:

      <tr th:each="prod : ${prods}">
        <td th:text="${prod.name}">Onions</td>
        <td th:text="${prod.price}">2.41</td>
        <td th:text="${prod.inStock}? #{true} : #{false}">yes</td>
      </tr>
输入:

<input type="text" name="userName" value="James Carrot" th:value="${user.name}" />


value为placeholder,value输入后会被解析覆盖
又如:

<form action="/gtvg/subscribe">
  <fieldset>
    <input type="text" name="email" />
    <input type="submit" value="¡Suscríbeme!"/>
  </fieldset>
</form>





 1.Text literals: '...'
 2.Number literals: 0,1.0,12.3,etc

Simple expression: 表达式语法
     1.Message expression : #{}
     2.Variable expression : ${}
     3.Link URL expression: @{}
     4.Selection Variable expression: *{}
        结合th:object使用,在某个范围内进行变量的查找,而不是在context中查找,缩小了查询的范围,效率如何呢?
        如何没有与th:object结合使用,*{}与${}效果一样,因为其范围自动扩展到context。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值