1.字符串/图片/map集合

  @GetMapping("/hello")
public String test(Model model){
String message="first thymeleaf !!";
model.addAttribute("message",message);
User u = new User();
u.setId(1);
u.setName("ttttttt");
u.setAge(18); Map<String,Object> map=new HashMap<>();
map.put("s1","/static/1.jpg");
map.put("s2","/static/2.jpg"); model.addAttribute("message", message);
model.addAttribute("user", u);
model.addAttribute("src", map);
return "index2";
}
index2.html

<body>
<h1 th:text="${message}"></h1> <img th:src="${src.s1}"/></br>
<img th:src="${src.s2}"/></br> 实体类信息<br>
<span th:text="${user.id}"></span>
<span th:text="${user.name}"></span>
<span th:text="${user.age}"></span> <br>
</body>

访问:http://localhost:8080/test/hello

结果:

2.List集合

@GetMapping("/hello2")
public String test2(Model model){
List<User> list=new ArrayList<User>();
User u1 = new User();
u1.setId(1);
u1.setName("11111111");
u1.setAge(18);
list.add(u1); User u2 = new User();
u2.setId(2);
u2.setName("2222222222");
u2.setAge(28);
list.add(u2);
User u3 = new User();
u3.setId(3);
u3.setName("3333333333");
u3.setAge(88);
list.add(u3); User u4 = new User();
u4.setId(4);
u4.setName("4444444444");
u4.setAge(888);
list.add(u4); model.addAttribute("userList", list);
return "index3";
}
<body>
<table width="200" style="text-align: center;">
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>index</th>
</tr>
<tr th:each="user,iterStat : ${userList}">
<td th:text="${user.id}"></td>
<td th:text="${user.name}"></td>
<td th:text="${user.age}"></td>
<td th:text="${iterStat.index}">index</td>
</tr>
</table>
</body>

Springboot---显示图片/字符串/map集合/list集合的更多相关文章

  1. img src 直接显示图片字符串,微信例子

    <div class="weui-cell__hd"><img src="data:image/png;base64,iVBORw0KGgoAAAANS ...

  2. java字符串,数组,集合框架重点

    1.字符串的字面量是否自动生成一个字符串的变量? String  str1  =  “abc”; Sring  str2  =   new String (“abc”); 对于str1:Jvm在遇到双 ...

  3. python之字符串,列表,字典,元组,集合内置方法总结

    目录 数字类型的内置方法 整型/浮点型 字符串类型的内置方法 列表的内置方法 字典的内置方法 元组的内置方法 集合类型内置方法 布尔类型 数据类型总结 数字类型的内置方法 整型/浮点型 加 + 减 - ...

  4. C#中服务端接受前端JSON字符串转换成字典集合

    我们是否可以把从前端接受的JSON字符串转换成字典集合呢? 比如从前端接收:{'size':'10', 'weight':'10kg'} 在服务端转换成:[{size:"10"}, ...

  5. 数组转集合、集合转数组、字符串数组与int型、long型数组等的转换

    在项目中经常会遇到数组转集合.集合转数组.数组之间类型转换等操作 1.数组转集合 为了实现把一个数组转换成一个ArrayList,很多Java程序员会使用如下的代码: String str[] = { ...

  6. Python基础(4)列表、元组、字符串、字典、集合、文件操作

    列表.元组操作 字符串操作 字典操作 集合操作 文件操作 字符编码与转码 详见:http://www.cnblogs.com/alex3714/articles/5717620.html 1.列表和元 ...

  7. Python之路【第二篇】: 列表、元组、字符串、字典、集合

    本文内容: -------------------------------------- 列表.元组操作 字符串操作 字典操作 集合操作 文件操作 字符编码与转码 1. 列表(list) 序列是Pyt ...

  8. Python小白的发展之路之Python基础(二)【字符串、列表、集合、文件操作】

    列表.元组操作 字符串操作 字典操作 集合操作 文件操作 字符编码与转码 1.列表.元组操作 (1)列表 列表是可变的(mutable)——可以改变列表的内容,这不同于字符串和元组,字符串和元组都是不 ...

  9. Delphi 读取 c# webservice XML的base64编码图片字符串转化图片并显示

    Delphi 读取 c# webservice XML的base64编码图片字符串转化图片并显示 在 开发中遇到应用c#及asp.net的在的webservice 保存图片并以xml文件形式现实出来 ...

随机推荐

  1. 「题解」「美团 CodeM 资格赛」跳格子

    目录 「题解」「美团 CodeM 资格赛」跳格子 题目描述 考场思路 思路分析及正解代码 「题解」「美团 CodeM 资格赛」跳格子 今天真的考自闭了... \(T1\) 花了 \(2h\) 都没有搞 ...

  2. CentOS修改各大yum源(centos5,centos6,centos7)

    备份原配置文件 进入yum源配置目录: cd /etc/yum.repos.d 如果没有先安装wget: sudo yum install wget 修改yum源,就是修改CentOS-Base.re ...

  3. 笔记-python-standard library-8.3.collections

    笔记-python-standard library-8.3.collections 1.      collections简介 Source code: Lib/collections/__init ...

  4. Docker示例命令

    1.docker run -t -i -v /root/workspace/node:/home/exam:rw docker.io/node bin/sh    -t 给容器挂载一个伪终端    - ...

  5. mysql 统计索引执行情况

    select distinct b.TABLE_SCHEMA,b.TABLE_NAME , b.INDEX_NAME , a.count_starfrom performance_schema.tab ...

  6. linux 从一台服务器向另台服务器复制文件

    使用scp命令: sudo scp -P 2222 username@192.168.0.200:/home/db/db_data.sql.gz /home/db/db_data.sql.gz scp ...

  7. FFmpeg调用c语言SDK实现日志的打印

    日志文件的三大步 // 导入头文件 #include <libavutil/log.h> // 设置日志级别 av_log_set_level(AV_LOG_DEBUG); //DEBUG ...

  8. nginx_2_nginx进程模型

    1.nginx进程模型概述 在上一节我们已经已经成功在linux服务器上安装了nginx,启动nginx后,查看进程:ps -ef | grep nginx 能看到启动nginx进程后,有一个mast ...

  9. 使用element-ui组件el-table时需要修改某一行或列的样式(包含解决选择器无效问题)

    在后台管理系统项目中,经常会使用element-ui中的组件el-table(表格)来展示列表数据. 当展示数据的时候,可能就需要给给某一行或者列设置特殊的样式,在查询文档是我遇到了一些问题:包括设置 ...

  10. windows环境变量引发的血案

    最近重装了系统,决心使用Anaconda来管理python包和虚拟环境.在完成一系列配置后,运行程序,发现老是报错 D:\Anaconda3\envs\jobnote>python E:\wor ...