当前位置:网站首页>Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
2022-07-05 14:18:00 【fengyehongWorld】
Catalog
Background data preparation
public ZTestEntity init3() {
ZTestEntity zTestEntity = new ZTestEntity();
zTestEntity.setIsAdmin(true);
zTestEntity.setName(" Jia Feitian ");
return zTestEntity;
}
// ------------------------------------------------
@GetMapping("/init3")
public ModelAndView init3() {
ModelAndView modelAndView = new ModelAndView();
ZTestEntity entity = service.init3();
modelAndView.addObject("entity", entity);
modelAndView.setViewName("test3");
return modelAndView;
}
The front desk
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<style> .content {
color: red; } .preAttr {
margin-top: 10px; } .test3 {
border: 1px solid yellow; } </style>
<title>test3 Title of the page </title>
</head>
<body>
<div id="container" th:object="${entity}">
<!-- // Omit ...... -->
</div>
</body>
</html>
One . th:classappend
<!-- When isAdmin by true when , Additional test3 attribute ; Otherwise, nothing will be done -->
<div class="content" th:classappend="*{isAdmin} ? test3 : _">th:classappend Test content </div>
After rendering
Two . th:styleappend
<!-- When isAdmin by true when , Additional margin-top:50px The style of ; Otherwise, do nothing -->
<div style="color: pink;" th:styleappend="*{isAdmin} ? 'margin-top:50px' : _">th:styleappend Test content </div>
After rendering
3、 ... and . Custom properties
<!-- data- Custom attributes can be directly accessed through th: In the form of -->
<div th:data-custom-name="*{name}">th:data- Property test content </div>
<!-- th: Any attribute name The way , You can add any attribute -->
<div th:haha="*{name}">th: Any attribute test content </div>
<hr>
After rendering
Four . data-th- How to write the attribute name
<!-- data-th- Property name and th: Attribute names work the same , It's just that the writing is different -->
<div data-th-class="*{name}">data-th- Test content </div>
<div th:class="*{name}">th:class Test content </div>
After rendering
边栏推荐
- Detailed explanation of IP address and preparation of DOS basic commands and batch processing
- 分享 12 个最常用的正则表达式,能解决你大部分问题
- Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
- 动态规划
- PHP5下WSDL,SOAP调用实现过程
- How to call the function mode of one hand and one machine
- 用“新”字来吸引好奇的人群
- 神经网络物联网未来发展趋势怎么样
- R language ggplot2 visualization: gganimate package is based on Transition_ The time function creates dynamic scatter animation (GIF) and uses shadow_ Mark function adds static scatter diagram as anim
- 登录界面代码
猜你喜欢
Tdengine biweekly selection of community issues | phase III
Postman简介、安装、入门使用方法详细攻略!
Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
Simple process of penetration test
Kunlun Taike rushes to the scientific innovation board: the annual revenue is 130million, and it plans to raise 500million. CETC Taiji holds 40% of the shares
Thymeleaf th:classappend属性追加 th:styleappend样式追加 th:data-自定义属性
Sharing the 12 most commonly used regular expressions can solve most of your problems
Redis如何实现多可用区?
随机推荐
mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
如何将 DevSecOps 引入企业?
LeetCode_ 67 (binary sum)
分享 12 个最常用的正则表达式,能解决你大部分问题
关于Apache Mesos的一些想法
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
基于 TiDB 场景式技术架构过程 - 理论篇
LeetCode_ 3 (longest substring without repeated characters)
WebRTC的学习(二)
poi设置列的数据格式(有效)
R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
VC开发非MFC程序内存泄漏跟踪代码
广发期货排名多少?网上办理广发期货开户安全可靠吗?
01. Solr7.3.1 deployment and configuration of jetty under win10 platform
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
Why do mechanical engineers I know complain about low wages?
OSI and tcp/ip protocol cluster