当前位置:网站首页>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 category does the Internet of things application technology major belong to
- ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
- 享你所想。智创未来
- IP packet header analysis and static routing
- The function of qualifier in C language
- Thymeleaf 常用函数
- R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
- The forked VM terminated without saying properly goodbye
- 做自媒体视频二次剪辑,怎样剪辑不算侵权
- POI set the data format of the column (valid)
猜你喜欢
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
Introduction, installation, introduction and detailed introduction to postman!
What are the advantages and characteristics of SAS interface
-Web direction attack and defense world
Postman简介、安装、入门使用方法详细攻略!
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
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
Sharing the 12 most commonly used regular expressions can solve most of your problems
Tiflash compiler oriented automatic vectorization acceleration
Lepton 无损压缩原理及性能分析
随机推荐
Tdengine biweekly selection of community issues | phase III
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
周大福践行「百周年承诺」,真诚服务推动绿色环保
一网打尽异步神器CompletableFuture
[buuctf.reverse] 152-154
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
Mysql database installation tutorial under Linux
别不服气。手机功能升级就是强
The function of qualifier in C language
What is the future development trend of neural network Internet of things
做自媒体视频二次剪辑,怎样剪辑不算侵权
The forked VM terminated without saying properly goodbye
Time to calculate cron expression based on cronsequencegenerator
循环不变式
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
Postman简介、安装、入门使用方法详细攻略!
基于 TiDB 场景式技术架构过程 - 理论篇
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
03_Solr之dataimport
TiCDC 6.0原理之Sorter演进