When we used the Springboot framework, we introduced the Thymelea engine template earlier because of Springboot's appalling support for JSP. So how can we load Dynamic Data on a static HTML page when we use the engine template to render the front page with the ability to return it? At this time we will introduce some basic methods of using Thymeleaf.
First, and our JSP page to import the C font is the same, we need to make certain configuration: as shown in the HTML tag to add two paragraphs
Text display: I saved a user object with a key value of User1 in the session, and I want to display its name directly on the page: use Th:text to
* Number arithmetic: We want to show all the properties of an object, this object has more than 10 properties, each time we have to use the object. Is the property displayed? At this point, the * operation arises:
Of course, our object creation is not necessarily only in Div, but also in block-level elements such as table.
If condition operation:
Selected Selection box default:
Each loop: Alias selection is used, which is similar to the item and VAR two properties of the foreach tag
Time Conversion: We use the data of date type directly when we use the background data time is very impersonal, so Thymeleaf provides the method of time conversion
URL Path Address:
Of course, we inevitably still need to be in the HTML page CSS and JS reference, then we should use when referring to:
1> configuration application.yml file: Because all of the static resources that we default in the Springboot framework are in the static folder
2> Edit JS File:
3>html page for reference:
Springboot Introduction to basic use of--thymeleaf engine templates