当前位置:网站首页>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 
边栏推荐
- 为什么我认识的机械工程师都抱怨工资低?
- 最简单不用证书也可以多开功能的方式
- The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
- Sharing the 12 most commonly used regular expressions can solve most of your problems
- Why do mechanical engineers I know complain about low wages?
- Linux下mysql数据库安装教程
- 04_ Use of solrj7.3 of solr7.3
- Detailed explanation of SSH password free login
- PHP5下WSDL,SOAP调用实现过程
- Getting started with rce
猜你喜欢

Sqllab 1-6 exercise

How to introduce devsecops into enterprises?

upload (1-6)

魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問

Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder

How to deeply understand the design idea of "finite state machine"?

What category does the Internet of things application technology major belong to

Detailed explanation of IP address and preparation of DOS basic commands and batch processing

IP packet header analysis and static routing

Postman简介、安装、入门使用方法详细攻略!
随机推荐
Use the word "new" to attract curious people
分享 12 个最常用的正则表达式,能解决你大部分问题
汇编语言 assembly language
Sorter evolution of ticdc 6.0 principle
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
04_ Use of solrj7.3 of solr7.3
Time to calculate cron expression based on cronsequencegenerator
周大福践行「百周年承诺」,真诚服务推动绿色环保
Hongmeng fourth training
What category does the Internet of things application technology major belong to
How can non-technical departments participate in Devops?
Implementation process of WSDL and soap calls under PHP5
The function of qualifier in C language
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
PHP5下WSDL,SOAP调用实现过程
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
What are the advantages and characteristics of SAS interface
C语言中限定符的作用
【学习笔记】图的连通性与回路
The forked VM terminated without saying properly goodbye