当前位置:网站首页>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 
边栏推荐
- R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
- How to deeply understand the design idea of "finite state machine"?
- Guofu hydrogen energy rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, and 360million yuan of accounts receivable exceed the revenue
- SSH免密码登录详解
- R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置
- LeetCode_ 67 (binary sum)
- After the microservice project is deployed, static resources and files uploaded to upload cannot be accessed. Solution
- 怎么叫一手一机的功能方式
- Postman简介、安装、入门使用方法详细攻略!
- Redis如何实现多可用区?
猜你喜欢

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

Simple process of penetration test

Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module

Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)

Introduction, installation, introduction and detailed introduction to postman!

Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million

Scenario based technology architecture process based on tidb - Theory

Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析

乌卡时代下,企业供应链管理体系的应对策略
随机推荐
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
Don't be unconvinced. Mobile phone function upgrade is strong
mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
区间 - 左闭右开
广发期货排名多少?网上办理广发期货开户安全可靠吗?
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
tidb-dm报警DM_sync_process_exists_with_error排查
The function of qualifier in C language
What are the advantages and characteristics of SAS interface
R语言使用ggplot2包的geom_histogram函数可视化直方图(histogram plot)
What category does the Internet of things application technology major belong to
强联通分量
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
Thymeleaf th:classappend属性追加 th:styleappend样式追加 th:data-自定义属性
The simplest way to open more functions without certificates
LeetCode_ 3 (longest substring without repeated characters)
How can non-technical departments participate in Devops?