后台返回缩略图设置成背景,th:style的background动态设置。
初始样式设置:

<div class="imgbox"
th:style="background:url('thumbnai.jpg') no-repeat center center; background-size: auto 100%;">
</div>

用后台返回的缩略图,代码如下:

<div class="imgbox"
th:style="'background:url(' + ${olist.thumbnail}+') no-repeat center center;
 background-size: auto 100%;'">
</div>

如果返回的缩略图字段为null, 页面报错。so加一层判断在外层:

<div class="imgbox"
th:style="${olist.thumbnail}?'background:url(' + ${olist.thumbnail}+') no-repeat center center;
 background-size: auto 100%;':''">
</div>

Thymeleaf 模板语言th:style添加background样式相关推荐

  1. thymeleaf 模板语言简介

    参考网址: https://blog.csdn.net/mlin_123/article/details/51816533 1.1 Thymeleaf 在有网络和无网络的环境下皆可运行,而且完全不需启 ...

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

    SpringBoot thymeleaf使用方法,thymeleaf模板迭代 SpringBoot thymeleaf 循环List.Map ============================= ...

  3. thymeleaf模板的使用(转)

    作者:纯洁的微笑 出处:http://www.ityouknow.com/ 在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thym ...

  4. Spring Boot - Thymeleaf模板简介以及集成

    文章目录 Spring Boot - Thymeleaf模板简介以及集成 1.什么是Thymeleaf? 2.标准表达式 2.1 变量表达式 2.2 选择表达式/星号表达式 2.3 URL表达式 2. ...

  5. SpringBoot框架+Thymeleaf模板引擎实现发送HTML格式邮件(可带附件)

    spring-boot-mail 项目结构 1.Maven工程依赖坐标 注意:SpringBoot版本需为2.x 若spring boot版本为1.x, <?xml version=" ...

  6. Springboot整合thymeleaf模板

    Thymeleaf是个XML/XHTML/HTML5模板引擎,可以用于Web与非Web应用. Thymeleaf的主要目标在于提供一种可被浏览器正确显示的.格式良好的模板创建方式,因此也可以用作静态建 ...

  7. 【SpringBoot】3、SpringBoot中整合Thymeleaf模板引擎

    SpringBoot 为我们提供了 Thymeleaf 自动化配置解决方案,所以我们在 SpringBoot 中使用 Thymeleaf 非常方便 一.简介 Thymeleaf是一个流行的模板引擎,该 ...

  8. Marco's Java【SpringBoot入门(六) 之 Thymeleaf模板引擎的使用】

    前言 本节呢给大家介绍一个新鲜 "玩意儿" 叫做Thymeleaf,Thymeleaf翻译过来就是 "百里香叶" 的意思 我发现这些大佬儿特别喜欢用叶子作为标识 ...

  9. Thymeleaf模板引擎+Spring整合使用方式的介绍

    尊重原创,原文地址为:https://www.cnblogs.com/jiangchao226/p/5937458.html 前言 这个教程介绍了Thymeleaf与Spring框架的集成,特别是Sp ...

最新文章

  1. NLPML_总结_20210208
  2. 4.6、Libgdx线程介绍
  3. 【已解决】GO语言开发中调用另一个库报错 cannot refer to unexported name XXXX
  4. LeetCode 82 删除排序链表中的重复元素 II python
  5. 《小团队构建大网站:中小研发团队架构实践》送书活动结果公布
  6. 算法笔记 -- 离散化
  7. Python 线程队列 LifoQueue – LIFO - Python零基础入门教程
  8. UE4 Slate概述
  9. FCKeditor上传漏洞总结
  10. “考不上本科是智商有问题”,这位吴先生火了!涉事公司回应...
  11. python基础教程第三版-Python基础教程(第三版)(七)再谈抽象
  12. Myeclipse6.5中安装maven
  13. 2017 5月12日上午
  14. 验证性因素分析AVE和CR值
  15. 新中大冲刺科创板:年营收2.84亿 拟募资5.57亿
  16. 如何检测页面是否允许访问Cookie
  17. 生活随记 - 75公斤重 急需减肥
  18. websocket前端向后端传数据时出现Buffer
  19. Java 进程启停及诊断 Jarboot大改版、焕然一新
  20. LTS = Long Term Support:长期支持版本

热门文章

  1. html实现下拉跳转
  2. 竞品分析----夸克:我离百度还有多少步?
  3. 小小知识点(一):辨别性相似度(Discriminative Similarity)
  4. 快来看,你的盒子也能用OpenCV NPU后端啦
  5. 为什么能力越低的人,越容易产生对自己过高的评价?
  6. 【UER #7】套路
  7. acer 服务器装系统,acer重装系统图文教程
  8. 怎样赚钱?互联网赚钱才是草根最好的方式!
  9. 在哪个范围内的计算机网络可以称为局域网,计算机网络概述 习题
  10. 华硕主板反复进入BIOS以及无法识别固态硬盘?