In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "Thymeleaf asterisk expression", so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Thymeleaf asterisk expression how to use" article.
When working with templates, you typically use the variable expression ${.} to display variables, and you can also use the selected object expression * {.}, also known as an asterisk expression.
If the object is selected first in the template, you need to use an asterisk expression. Thymeleaf's built-in object # object effect is equivalent to an asterisk expression.
Development environment: IntelliJ IDEA 2019.2.2
Spring Boot version: 2.1.8
Create a new Spring Boot project named demo.
1 、 pom.xml
Join Thymeleaf dependency
Org.springframework.boot spring-boot-starter-thymeleaf
2 、 src/main/java/com/example/demo/User.java
Package com.example.demo;public class User {Integer id; String name; public User (Integer id, String name) {this.id = id; this.name = name;} public Integer getId () {return id;} public void setId (Integer id) {this.id = id;} public String getName () {return name } public void setName (String name) {this.name = name;}}
3 、 src/main/java/com/example/demo/TestController.java
Package com.example.demo;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import java.util.ArrayList;import java.util.List;@Controllerpublic class TestController {@ RequestMapping ("/") public String test (Model model) {List users = queryUsers (); model.addAttribute ("user", users.get (0)); model.addAttribute ("users", users); return "test" } private List queryUsers () {List users = new ArrayList (); users.add (new User (1, "Zhang San"); users.add (new User (2, "Li Si"); users.add (new User (3, Wang Wu)); return users;}}
4 、 src/main/resources/templates/test.html
Title table {border-collapse:collapse;} td {border: 1px solid # C1DAD7 } use variable expressions use asterisk expressions: use asterisk expressions: use # object objects to use asterisk expressions in the body of a loop
Browser access: http://localhost:8080
The following screenshot is shown:
The above is about the content of this article on "how to use Thymeleaf asterisk expressions". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.