ThymeLeaf前端模板简单使用

匿名 (未验证) 提交于 2019-12-03 00:03:02

<table border="1">

<tr th:each="skuImage:${skuInfo.skuImageList}">

<td th:text="${skuImage.id}"></td>

<td th:text="${skuImage.imgName}"></td

tr>

</table

<table>

<!-- <c:foreach items="${arrayList}" var = "arry">-->

<tr th:each="arry,stat: ${arrayList}">

<td th:text="${arry}"></td>

<td th:text="${stat.index}"></td>

</tr>

</table>

  • ThymeLeaf特点:

      1. ThymeLeaf:建立在自然模板上(H5标签),渲染数据的时候,都是一些h5的扩展标签属性。

      2. jsp:建立在自然模板上,渲染数据的时候,需要使用JSTL,EL表示式。

    1. ThymeLeaf与FreeMarker比较

      1. ThymeLeaf:建立在自然模板上。

      2. FreeMarker:必须先用ftl模板。

  • ThymeLeaf的使用:

    1. 现在页面中引入ThymeLeaf的命名空间 (页面开头的html标签替换)

    2. 在后台存值,前台显示。

  • ThymeLeaf标签:

    • 带索引的循环

    • 取session中的值

div th:text="${session.userName}"> </div

    • <div th:include="itemInner"/>

  • 判断

    • 三元运算:

    • <td th:text="(${skuImage.id}=='10')?'是10':'不是10'"></td<td th:text="${类.属性名}==值?'正确的输出结果':'错误的输出结果'">

    • 普通判断

    • <td th:if=>123456</td 如果判断成立,直接输出123,如果没有th:text标签,那么就输出div标签中的123456

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!