当前位置:网站首页>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
边栏推荐
- What is the future development trend of neural network Internet of things
- R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to each vari
- SSH免密码登录详解
- 微服务项目部署后,无法访问静态资源,无法访问到上传到upload中的文件,解决办法
- SAS接口有什么优势特点
- R language dplyr package select function, group_ By function, mutate function and cumsum function calculate the cumulative value of the specified numerical variable in the dataframe grouping data and
- 日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
- Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million
- 鸿蒙第四次培训
- R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
猜你喜欢
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
Sqllab 1-6 exercise
Sorter evolution of ticdc 6.0 principle
What is the future development trend of neural network Internet of things
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
TiCDC 6.0原理之Sorter演进
魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
神经网络物联网未来现状和趋势及看法
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
Tdengine biweekly selection of community issues | phase III
随机推荐
矩阵链乘 - 动态规划实例
根据CronSequenceGenerator计算cron表达式的时间
Thymeleaf 常用函数
POI set the data format of the column (valid)
Google EventBus 使用详解
R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
tidb-dm报警DM_sync_process_exists_with_error排查
The function of qualifier in C language
How to make a second clip of our media video without infringement
魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
Current situation, trend and view of neural network Internet of things in the future
Linux下mysql数据库安装教程
最长公共子序列 - 动态规划
upload (1-6)
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
广发期货排名多少?网上办理广发期货开户安全可靠吗?
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
04_ Use of solrj7.3 of solr7.3
R language dplyr package select function, group_ By function, mutate function and cumsum function calculate the cumulative value of the specified numerical variable in the dataframe grouping data and
Detailed explanation of SSH password free login