当前位置:网站首页>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)
- The forked VM terminated without saying properly goodbye
- Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
- 别不服气。手机功能升级就是强
- 最长公共子序列 - 动态规划
- Scenario based technology architecture process based on tidb - Theory
- 如何将 DevSecOps 引入企业?
- 04_ Use of solrj7.3 of solr7.3
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- Lepton 无损压缩原理及性能分析
猜你喜欢

神经网络物联网未来现状和趋势及看法

What is the future development trend of neural network Internet of things

Why do mechanical engineers I know complain about low wages?

循环不变式

LeetCode_ 2 (add two numbers)

乌卡时代下,企业供应链管理体系的应对策略

网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理

IP packet header analysis and static routing

如何深入理解“有限状态机”的设计思想?

无密码身份验证如何保障用户隐私安全?
随机推荐
Sharing the 12 most commonly used regular expressions can solve most of your problems
【学习笔记】图的连通性与回路
软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】
PHP5下WSDL,SOAP调用实现过程
LeetCode_ 67 (binary sum)
鸿蒙第四次培训
Simple process of penetration test
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
强联通分量
Lepton 无损压缩原理及性能分析
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
Hongmeng fourth training
Use the word "new" to attract curious people
Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu
C - Divisors of the Divisors of An Integer Gym - 102040C
How to protect user privacy without password authentication?
How to introduce devsecops into enterprises?
Detailed explanation of SSH password free login
一网打尽异步神器CompletableFuture
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列