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

SpringBoot thymeleaf 循环List、Map

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

©Copyright 蕃薯耀 2018年3月27日

http://www.cnblogs.com/fanshuyao/

附件下载见:http://fanshuyao.iteye.com/blog/2414521

一、thymeleaf模板基本显示:

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

二、迭代List

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

三、students集合对象迭代

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

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

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

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

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

六、Map迭代

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

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

1、基本语法:

2、对应的属性:

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

©Copyright 蕃薯耀 2018年3月27日

http://www.cnblogs.com/fanshuyao/

SpringBoot thymeleaf使用方法,thymeleaf模板迭代的更多相关文章

  1. springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息

    1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...

  2. SpringBoot Web开发(4) Thymeleaf模板与freemaker

    SpringBoot Web开发(4) Thymeleaf模板与freemaker 一.模板引擎 常用得模板引擎有JSP.Velocity.Freemarker.Thymeleaf SpringBoo ...

  3. SpringBoot 整合 Thymeleaf & 如何使用后台模板快速搭建项目

    如果你和我一样,是一名 Java 道路上的编程男孩,其实我不太建议你花时间学 Thymeleaf,当然他的思想还是值得借鉴的.但是他的本质在我看来就是 Jsp 技术的翻版(Jsp 现在用的真的很少很少 ...

  4. springboot之freemarker 和thymeleaf模板web开发

    Spring Boot 推荐使用Thymeleaf.FreeMarker.Velocity.Groovy.Mustache等模板引擎.不建议使用JSP. 一.Spring Boot 中使用Thymel ...

  5. java框架之SpringBoot(4)-资源映射&thymeleaf

    资源映射 静态资源映射 查看 SpringMVC 的自动配置类,里面有一个配置静态资源映射的方法: @Override public void addResourceHandlers(Resource ...

  6. SpringBoot整合Jsp和Thymeleaf (附工程)

    前言 本篇文章主要讲述SpringBoot整合Jsp以及SpringBoot整合Thymeleaf,实现一个简单的用户增删改查示例工程.事先说明,有三个项目,两个是单独整合的,一个是将它们整合在一起的 ...

  7. SpringBoot(四) Web开发 --- Thymeleaf、JSP

    Spring Boot提供了spring-boot-starter-web为Web开发予以支持,spring-boot-starter-web为我们提供了嵌入的Tomcat以及Spring MVC的依 ...

  8. SpringBoot学习笔记(4)----SpringBoot中freemarker、thymeleaf的使用

    1. freemarker引擎的使用 如果你使用的是idea或者eclipse中安装了sts插件,那么在新建项目时就可以直接指定试图模板 如图: 勾选freeMarker,此时springboot项目 ...

  9. 玩转 SpringBoot 2 快速整合 | Thymeleaf 篇

    前言 Thymeleaf是一个适用于Web和独立环境的现代服务器端Java模板引擎. Thymeleaf的主要目标是为您的开发工作流程带来优雅的自然模板 - 可以在浏览器中正确显示的HTML,也可以用 ...

随机推荐

  1. 你不知道的js

    1.<a>标签 (1)href属性包含超链接或超链接指向的URL或URL片段,URL 片段是哈希标记(#)前面的名称,哈希标记指定当前文档中的内部目标位置(HTML 元素的 ID).URL ...

  2. ITxlab倡议启动“互联网X大脑”计划

    导语:"互联网X大脑"计划由ITxlab(互联网X实验室)联合科学院相关机构.基于7年以来取得的研究成果,倡议建立的互联网与脑科学前沿研究平台,吸引不同领域专家进行科学研究和成果交 ...

  3. API判断本机安装的Revit版本信息

    start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class c ...

  4. Hessian学习总结(二)——使用hessian上传文件

    hessian较早版本通过 byte[] 进行文件传输:4.0之后支持 InputStream 作为参数或返回值进行传输. 注意:hessian会读取整个文件,如果文件过大,会导致JVM内存溢出.可以 ...

  5. EBS MOAC

    alter session set nls_language='SIMPLIFIED CHINESE';alter session set nls_language ='AMERICAN'; exec ...

  6. String literal is not properly closed by a double-quote eclipse

    中文乱码, 解决方法之一就是更改工程的编码方式. 首先选择工程,右键打开property窗口,resource下的text  file incoding,看看是不是选择的utf-8,如果不是的话更改为 ...

  7. 【docker】docker部署spring boot服务,但是docker logs查看容器输出控制台日志,没有日志打印,日志未打印,docker logs不打印容器日志

    如题: docker部署spring boot服务,但是docker logs查看容器输出控制台日志,没有日志打印,日志未打印,docker logs不打印容器日志 场景再现: docker部署并启动 ...

  8. Java Comparator字符排序(数字、字母、中文混合排序)

    Java.lang.Character类 复习一下 这是修正前的排序效果: 这是修正后的排序效果: 完整示例: 以下是排序的部份代码(非全部代码:拼音首字母算法不在其中) import java.ut ...

  9. Dictionary简洁

    mydic_ShuiFei = new Dictionary<string, string>() {             {"00000336","南京市 ...

  10. 【Linux】Cent OS 虚拟机开机自启动配置

    一次断电,导致实体机关机了,虚拟机也连不上去,只好手动来起来. 我想增加一下自启动,让硬件开机的时候,自动启动虚拟机: 其实是有办法的,尝试了一下,也成功了,这里简单标记下. virsh autost ...