前言

  • spring boot 2.1.1.RELEASE
  • thymeleaf 3.0.11.RELEASE
  • thymeleaf 支持 HTML5 data-* 属性,比如: data-{prefix}-{name}
  • HTML5 data-* 属性

thymeleaf 支持 HTML5 data-* 属性

thymeleaf 支持使用 HTML5 data-* (data-th-开头)属性获取数据。

<table><tr data-th-each="user : ${users}"><td data-th-text="${user.login}">...</td><td data-th-text="${user.name}">...</td></tr>
</table>

上面的写法与下面的写法是等效的:

<table><tr th:each="user : ${users}"><td th:text="${user.login}">...</td><td th:text="${user.name}">...</td></tr>
</table>

HTML5 data-* 属性

设置 data-* 属性的值,需要使用 th:attr
thymeleaf 代码如下:

<div th:attr="data-id=${user.id}" > ... </div>

运行效果:

<div data-id="1003" > ... </div>

多个 HTML5 data-* 属性

逗号分割。比如:

<div th:attr="data-id=${user.id},data-name=${user.name},data-login=${user.login}" >...
</div>

js 获取 data-* 值

https://blog.csdn.net/sayyy/article/details/108776036

参考

https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#support-for-html5-friendly-attribute-and-element-names

【thymeleaf】data-*相关推荐

  1. 【spring boot】【thymeleaf】SPEL调用静态方法和静态属性

    前言 spring boot 2.1.1.RELEASE thymeleaf 3.0 静态属性 <sapn th:text="${T(java.lang.Math).PI}" ...

  2. 后端程序员如何写出优雅的前端试图【Thymeleaf】

    Thymeleaf Thymeleaf 是一个现代服务器端 Java 模板引擎,适用于 Web 和独立环境. [官网地址]:https://www.thymeleaf.org/ 文章目录 Thymel ...

  3. 【C】Data type

    系列连载 [python / C / C++] 参考 <C语言程序设计(第四版)谭浩强> [C语言]C语言视频教程 <郝斌 C 语言自学教程> 文章目录 C 语言概述 A.1 ...

  4. 【thymeleaf】【SpringBoot】在HTML中调用Spring Bean

    前言 spring boot : 2.0.0.RELEASE maven eclipse thymeleaf 3.0 某些情况下需要在HTML中调用Service.比如:做CMS系统时提供的随时获取文 ...

  5. 【转】data和attr的用法与区别

    attr()的用法 attr()获得属性值 通过attr()获得属性时,可以这样$(selector).attr(attrName).注意,其返回值始终是string型!  eg : 通过attr() ...

  6. 【thymeleaf】【SpringBoot】Thymeleaf 获取.properties中的配置项变量

    前言 略. Thymeleaf 获取.properties中的配置项变量 假设我在 Thymeleaf 中写JavaScript的时候,发现我需要读取application.properties中的配 ...

  7. 【thymeleaf 】在 thymeleaf 中使用 shiro 标签

    前言 sprint boot 2.3.4.RELEASE 说明 shiro 未提供对 thymeleaf 的支持.第三方项目 thymeleaf-extras-shiro 提供了在 thymeleaf ...

  8. 【spring boot】【thymeleaf】SPEL处理 null 值

    前言 spring boot 2.1.1.RELEASE thymeleaf 3.0 变量为 null 时,显示默认值 name?:'Unknown' 当 name 变量为 null 时,显示值 Un ...

  9. 【Spring Boot】【Thymeleaf】The SpringStandard Dialect

    前言 spring boot 2.1.1.RELEASE Thymeleaf 3.0 The SpringStandard Dialect 使用 Spring Expression Language ...

最新文章

  1. 「机器学习」机器学习算法优缺点对比(汇总篇)
  2. Java show两个整数加减_怎么样用java编写界面实现两个数的加法运算
  3. python函数拟合不规则曲线_python曲线拟合
  4. Windows7 IIS7.5 HTTP Error 503 The service is unavailable 另类解决方案
  5. k8s源码分析 pdf_rook源码分析之一:rook架构解析
  6. java 内部接口 内部类_Java的接口中中添加内部类,甚至实现外围接口的内部类,意义是什么?...
  7. 想要 24 小时自学编程,那是不可能的,先自学 10000 小时再说!
  8. java控制并发数量_Java并发编程中级篇(二):使用Semaphore信号量进行多个资源并发控制...
  9. Keras:基于Python的深度学习库
  10. 二维离散傅里叶变换 matlab
  11. 433M超再生无线模块编码-解码
  12. xzp android webview,加载gif动态图的三种方式
  13. WKWebView - 1
  14. 相思赋予谁 --知错
  15. css空心图形,css画空心箭头
  16. js 数组操作的push pop shift unshift 等方法
  17. 传递函数和状态方程互转
  18. 字符串写入到json文件
  19. Ubuntu20.04 OpenSlide 读图Bug 解决
  20. linux下安装包打包依赖库所走的弯路

热门文章

  1. 泰一指尚大数据应用成为第一批省级重点企业研究院
  2. 《Ceph源码分析》——第1章,第一节Ceph的发展历程
  3. idea代码调试debug篇
  4. Hadoop源码分析HDFS ClientProtocol——getBlockLocations
  5. C# AutoResetEvent
  6. 在Flex中使用HTTPService传递参数
  7. 计算机网络计算机应用答案,计算机网络与应用(含答案).doc
  8. php中 elseif和else if 的区别
  9. Ice-3.5.1在CentOS 6.5系统中的编译配置教程
  10. Elasticsearch 架构原理