当前位置:网站首页>Thymeleaf th:with use of local variables
Thymeleaf th:with use of local variables
2022-07-05 14:17:00 【fengyehongWorld】
Background data preparation
ZTestEntity zTestEntity = new ZTestEntity();
List<Person> personList = Arrays.asList(
new Person("1", " Jia Feitian ", "20")
, new Person("2", " Zhang San ", "21")
);
zTestEntity.setPersonList(personList);
return zTestEntity;
// ---------------------------------------------------
@GetMapping("/init2")
public ModelAndView init2() {
ModelAndView modelAndView = new ModelAndView();
ZTestEntity entity = service.init();
modelAndView.addObject("entity", entity);
modelAndView.setViewName("test2");
return modelAndView;
}
The front desk test2.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>test2 Title of the page </title>
</head>
<body>
<div id="container" th:object="${entity}">
<!-- Use th:with take person0Id and personInfo Is treated as a local variable , Act on div On any child element within -->
<div th:with=" person0Id=*{personList[0].personId} ,personInfo=*{personList[1]} ">
<!-- Inside div External use div Defined local variables -->
<div th:text="${person0Id}"></div>
<div>[[${personInfo.personId}]]</div>
<hr>
<!-- Thymeleaf Another way to write labels , Take advantage of html5 Of data- attribute th: Tag name All can be used data-th- This form of tag name is used to replace -->
<div data-th-text="${personInfo.personName}"></div>
</div>
</div>
</body>
</html>
effect
边栏推荐
- Linux下mysql数据库安装教程
- How to call the function mode of one hand and one machine
- R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
- R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
- Don't be unconvinced. Mobile phone function upgrade is strong
- ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
- POI set the data format of the column (valid)
- VC开发非MFC程序内存泄漏跟踪代码
- LeetCode_ 2 (add two numbers)
- Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
猜你喜欢
Tdengine biweekly selection of community issues | phase III
网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理
如何深入理解“有限状态机”的设计思想?
非技术部门,如何参与 DevOps?
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
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
周大福践行「百周年承诺」,真诚服务推动绿色环保
基于 TiDB 场景式技术架构过程 - 理论篇
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
随机推荐
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
The function of qualifier in C language
强联通分量
汇编语言 assembly language
Scenario based technology architecture process based on tidb - Theory
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
根据CronSequenceGenerator计算cron表达式的时间
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
LeetCode_ 67 (binary sum)
-Web direction attack and defense world
[buuctf.reverse] 152-154
Linux下mysql数据库安装教程
MySQL user-defined function ID number to age (supports 15 / 18 digit ID card)
Catch all asynchronous artifact completable future
Postman简介、安装、入门使用方法详细攻略!
最长公共子序列 - 动态规划
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
Geom of R language using ggplot2 package_ Histogram function visual histogram (histogram plot)
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少