In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of "how to use Thymeleaf operator". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use Thymeleaf operator" can help you solve the problem.
The constant of Thymeleaf expression syntax is divided into string constant, numeric constant, Boolean constant and null constant.
Operators are divided into arithmetic operators, relational operators, conditional operators, and no operators.
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/TestController.java
Package com.example.demo;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class TestController {@ RequestMapping ("/") public String test (Model model) {model.addAttribute ("flag", true); return "test";}}
3 、 src/main/resources/templates/test.html
1. Expression constant 1, string constant: use single quotation marks, or | if double quotation marks contain only "a-zA-Z0-9 []-_", you can also omit single quotation marks. In other cases, exception 2, numeric constant 3, Boolean constant: = = true statement outside ${...} will be handled by Thymeleaf. Inside, it is handled by OGNL or SpringEL to show hidden 4, null constant display hidden 5, string concatenation: except for the append and concat methods of # strings objects You can also use the "+" sign, "|" symbol 2, arithmetic operator 1, addition 2, subtraction 3, multiplication 4, division: division can also use aliases div5, remainder: you can also use aliases mod III, relational operators are: >, =, 3, conditional operator 1, conditional operator expression is: (condition)? Then: else can also omit then2, and the default expression is: (value)?: (defaultValue), indicating that the value is returned directly if there is a value. Otherwise, the default value is returned. 4. No operator means no operation. When a value does not exist, use this symbol to specify that the expression does nothing, thus minimizing the damage to the prototype. For example, the prototype is: abc may use the statement: now you can use: abc
Browser access: http://localhost:8080
Page output:
1. Expression constant 1, string constant: use single quotation marks, or | Hello,WorldHello,World if the double quotation marks contain only "a-zA-Z0-9 []-_", you can also omit single quotation marks. In other cases, if you use commas, there will be an exception HelloWorld2, numeric constant 10303, Boolean constant: = = true statement outside ${.} will be handled by Thymeleaf. Inside, it is processed by OGNL or SpringEL to display 4, null constant 5, string concatenation: in addition to using the append and concat methods of # strings objects, you can also use the sign "+", "|" symbol abababb 2, arithmetic operator 1, addition 332, subtraction-1-13, multiplication 224, division: division can also use aliases div000.50.55, remainder: aliases mod111 III, relational operators are: >, =,
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.