Thymeleaf 模板语言th:style添加background样式
后台返回缩略图设置成背景,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样式相关推荐
- thymeleaf 模板语言简介
参考网址: https://blog.csdn.net/mlin_123/article/details/51816533 1.1 Thymeleaf 在有网络和无网络的环境下皆可运行,而且完全不需启 ...
- SpringBoot thymeleaf使用方法,thymeleaf模板迭代
SpringBoot thymeleaf使用方法,thymeleaf模板迭代 SpringBoot thymeleaf 循环List.Map ============================= ...
- thymeleaf模板的使用(转)
作者:纯洁的微笑 出处:http://www.ityouknow.com/ 在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thym ...
- Spring Boot - Thymeleaf模板简介以及集成
文章目录 Spring Boot - Thymeleaf模板简介以及集成 1.什么是Thymeleaf? 2.标准表达式 2.1 变量表达式 2.2 选择表达式/星号表达式 2.3 URL表达式 2. ...
- SpringBoot框架+Thymeleaf模板引擎实现发送HTML格式邮件(可带附件)
spring-boot-mail 项目结构 1.Maven工程依赖坐标 注意:SpringBoot版本需为2.x 若spring boot版本为1.x, <?xml version=" ...
- Springboot整合thymeleaf模板
Thymeleaf是个XML/XHTML/HTML5模板引擎,可以用于Web与非Web应用. Thymeleaf的主要目标在于提供一种可被浏览器正确显示的.格式良好的模板创建方式,因此也可以用作静态建 ...
- 【SpringBoot】3、SpringBoot中整合Thymeleaf模板引擎
SpringBoot 为我们提供了 Thymeleaf 自动化配置解决方案,所以我们在 SpringBoot 中使用 Thymeleaf 非常方便 一.简介 Thymeleaf是一个流行的模板引擎,该 ...
- Marco's Java【SpringBoot入门(六) 之 Thymeleaf模板引擎的使用】
前言 本节呢给大家介绍一个新鲜 "玩意儿" 叫做Thymeleaf,Thymeleaf翻译过来就是 "百里香叶" 的意思 我发现这些大佬儿特别喜欢用叶子作为标识 ...
- Thymeleaf模板引擎+Spring整合使用方式的介绍
尊重原创,原文地址为:https://www.cnblogs.com/jiangchao226/p/5937458.html 前言 这个教程介绍了Thymeleaf与Spring框架的集成,特别是Sp ...
最新文章
- NLPML_总结_20210208
- 4.6、Libgdx线程介绍
- 【已解决】GO语言开发中调用另一个库报错 cannot refer to unexported name XXXX
- LeetCode 82 删除排序链表中的重复元素 II python
- 《小团队构建大网站:中小研发团队架构实践》送书活动结果公布
- 算法笔记 -- 离散化
- Python 线程队列 LifoQueue – LIFO - Python零基础入门教程
- UE4 Slate概述
- FCKeditor上传漏洞总结
- “考不上本科是智商有问题”,这位吴先生火了!涉事公司回应...
- python基础教程第三版-Python基础教程(第三版)(七)再谈抽象
- Myeclipse6.5中安装maven
- 2017 5月12日上午
- 验证性因素分析AVE和CR值
- 新中大冲刺科创板:年营收2.84亿 拟募资5.57亿
- 如何检测页面是否允许访问Cookie
- 生活随记 - 75公斤重 急需减肥
- websocket前端向后端传数据时出现Buffer
- Java 进程启停及诊断 Jarboot大改版、焕然一新
- LTS = Long Term Support:长期支持版本