SpringBoot thymeleaf使用方法,thymeleaf模板迭代

SpringBoot thymeleaf 循环List、Map

 

================================

©Copyright 蕃薯耀 2018年3月26日

http://fanshuyao.iteye.com/

 

一、thymeleaf模板基本显示:

<div th>thymeleaf模板语言测试</div>
<div>您好, 
  <span class="cc" id="aaa" th:text="${myname}" th:id="${id}"></span>
</div>
<div class="cc" id="bbb" th:text="'姓名:'+${myname}" th:id="'id_'+${id}"></div>

 

二、迭代List

<div>==========List迭代==============</div>
<ul>
<li th:each="data : ${list}" th:text="${data}"></li>
</ul>

 

三、students集合对象迭代

<div>==========students迭代==============</div>
<ul>
  <li  th:each="student : ${students}" th:text="'姓名:' + ${student.name} + ',年龄:' + ${student.age}"></li>
</ul>

 

四、students集合对象迭代第二种方式,使用双竖线:|xxxx|

<div>==========students迭代2,使用双竖线:|xxxx|==============</div>
<ul>
    <li  th:each="student : ${students}" th:text="|姓名:${student.name} ,年龄:  ${student.age}|"></li>
</ul>

 

五、students集合对象迭代第三种方式,使用中括号:[[]]或[()],这2个的区别在对于特殊字符是否转义

<div>==========students迭代3,使用中括号:[[]]或[()]==============</div>
<ul>
    <li  th:each="student : ${students}" >姓名:[[${student.name}]],年龄:[(${student.age})]</li>
</ul>

 

六、Map迭代

<div>==========Map迭代==============</div>
<ul>
    <li  th:each="m : ${map}" >key:[[${m.key}]],值:[(${m.value})]</li>
</ul>

 

七、模板语言基本用法:(附件在Pdf文档:usingthymeleaf.pdf)

1、基本语法:


SpringBoot thymeleaf使用方法,thymeleaf模板迭代
 

2、对应的属性:


SpringBoot thymeleaf使用方法,thymeleaf模板迭代
 

 (如果你觉得文章对你有帮助,欢迎捐赠,^_^,谢谢!) 


SpringBoot thymeleaf使用方法,thymeleaf模板迭代    SpringBoot thymeleaf使用方法,thymeleaf模板迭代

 

================================

©Copyright 蕃薯耀 2018年3月26日

http://fanshuyao.iteye.com/

 

 

相关文章:

  • 2021-11-18
  • 2021-11-17
  • 2021-10-15
  • 2022-01-13
  • 2021-06-02
  • 2022-12-23
  • 2021-05-24
猜你喜欢
  • 2021-12-03
  • 2022-12-23
  • 2021-12-05
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案