thymeleaf常用的一些标签属性

来源:互联网 发布:淘宝上的whoo后真吗 编辑:程序博客网 时间:2024/06/07 11:43

原址:http://blog.csdn.net/zheng911209/article/details/48181285

用thymeleaf模版,总结了下经常用到的一些属性: 
从后台传过来一个List,需要到前端页面显示,所以一般先进行判断——该List是否为空,然后才是加载内容,而有些页面加载的时候需要获取序号,具体代码如下:

<th:block th:if="${not #lists.isEmpty(purchaseDemandList)}">    <li class="list-group-item row entry-default-child entry-default-xs weaker-font-color text-center">        <div><span>序号</span></div>        <div><span>名称</span></div>        <div><span>周期</span></div>        <div><span>数量</span></div>    </li>    <th:block th:each="purchaseDemand,index:${purchaseDemandList}">        <li class="list-group-item row entry-default-child entry-default-xs weaker-font-color text-center">            <div><span th:text="${index.count}">序号</span></div>            <div><span th:text="${purchaseDemand.goodsName}" >商品名称</span></div>            <div><span th:if="${purchaseDemand.purchaseCycle=='half_month'?'半个月':'一个月'}">采购周期</span></div>            <div><span th:text="${purchaseDemand.num}"> 数量</span></div>        </li>    </th:block></th:block>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

序号对象获取:

<th:block th:each="purchaseDemand,index:${purchaseDemandList}"><span th:text="${index}">序号</span></th:block>
  • 1
  • 2
  • 3

${index}结果如下: 
这里写图片描述

时间格式化

 th:text="${#calendars.format(nowTime,'yyyy-MM-dd')}"
  • 1


原创粉丝点击