SpringBoot thymeleaf使用方法,thymeleaf模板迭代
SpringBoot thymeleaf使用方法,thymeleaf模板迭代
SpringBoot thymeleaf 循环List、Map
================================
©Copyright 蕃薯耀 2018年3月27日
http://www.cnblogs.com/fanshuyao/
附件下载见:http://fanshuyao.iteye.com/blog/2414521
一、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、基本语法:
2、对应的属性:
================================
©Copyright 蕃薯耀 2018年3月27日
http://www.cnblogs.com/fanshuyao/
SpringBoot thymeleaf使用方法,thymeleaf模板迭代的更多相关文章
- springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息
1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...
- SpringBoot Web开发(4) Thymeleaf模板与freemaker
SpringBoot Web开发(4) Thymeleaf模板与freemaker 一.模板引擎 常用得模板引擎有JSP.Velocity.Freemarker.Thymeleaf SpringBoo ...
- SpringBoot 整合 Thymeleaf & 如何使用后台模板快速搭建项目
如果你和我一样,是一名 Java 道路上的编程男孩,其实我不太建议你花时间学 Thymeleaf,当然他的思想还是值得借鉴的.但是他的本质在我看来就是 Jsp 技术的翻版(Jsp 现在用的真的很少很少 ...
- springboot之freemarker 和thymeleaf模板web开发
Spring Boot 推荐使用Thymeleaf.FreeMarker.Velocity.Groovy.Mustache等模板引擎.不建议使用JSP. 一.Spring Boot 中使用Thymel ...
- java框架之SpringBoot(4)-资源映射&thymeleaf
资源映射 静态资源映射 查看 SpringMVC 的自动配置类,里面有一个配置静态资源映射的方法: @Override public void addResourceHandlers(Resource ...
- SpringBoot整合Jsp和Thymeleaf (附工程)
前言 本篇文章主要讲述SpringBoot整合Jsp以及SpringBoot整合Thymeleaf,实现一个简单的用户增删改查示例工程.事先说明,有三个项目,两个是单独整合的,一个是将它们整合在一起的 ...
- SpringBoot(四) Web开发 --- Thymeleaf、JSP
Spring Boot提供了spring-boot-starter-web为Web开发予以支持,spring-boot-starter-web为我们提供了嵌入的Tomcat以及Spring MVC的依 ...
- SpringBoot学习笔记(4)----SpringBoot中freemarker、thymeleaf的使用
1. freemarker引擎的使用 如果你使用的是idea或者eclipse中安装了sts插件,那么在新建项目时就可以直接指定试图模板 如图: 勾选freeMarker,此时springboot项目 ...
- 玩转 SpringBoot 2 快速整合 | Thymeleaf 篇
前言 Thymeleaf是一个适用于Web和独立环境的现代服务器端Java模板引擎. Thymeleaf的主要目标是为您的开发工作流程带来优雅的自然模板 - 可以在浏览器中正确显示的HTML,也可以用 ...
随机推荐
- POIUtil
package com.util.poi; import java.io.ByteArrayOutputStream; import java.io.IOException; import java. ...
- Implement strStr() leetcode java
题目: Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if ...
- nodejs sass安装报错一招解决
背景: 这个问题不是一天两天了,有时候是网速不行,有时候是被墙了,有时候是github把node-sass的包转移目录导致下载失败. Cannot download "https://git ...
- 学习Spring-Session+Redis实现session共享
1.添加依赖 <dependency> <groupId>org.springframework.session</groupId> <artifactId& ...
- android 异常:ScrollView can host only one direct child
android 采用ScrollView布局时出现异常:ScrollView can host only one direct child. 主要是ScrollView内部只能有一个子元素,即不能并列 ...
- ASP.NET MVC 自定义处理JSON ActionResult类
1.统一JSON格式处理方式,同时指定ContentType类型,解决低版本浏览器获取json时ContentType为application/json提示下载的问题. public abstract ...
- GuavaCache学习笔记一:自定义LRU算法的缓存实现
前言 今天在看GuavaCache缓存相关的源码,这里想到先自己手动实现一个LRU算法.于是乎便想到LinkedHashMap和LinkedList+HashMap, 这里仅仅是作为简单的复习一下. ...
- php手册总结《类》
手册页面: http://php.net/manual/zh/language.oop5.basic.php >> 类名 类名可以是任何非 PHP 保留字的合法标签.一个合法类名以字母或下 ...
- [svc]通过bridge连接单机的多个网络namespace
ip操作物理网卡 参考: http://www.cnblogs.com/iiiiher/p/8056930.html - 查看mac/操作物理网卡 ip link - 查看ip/mac ip a - ...
- elasticsearch和mysql排序问题
elasticsearch 字段类型错误 最近用elasticseach做排序,排序字段是float型的,没有使用mapping,是直接写代码导入的,没想到排序时如果有小数和整数就会出现错误. 于是查 ...