[Detailed explanation] Basic expressions in Thymeleaf: @{}, #{}, ${}, *{}

1. @{}: Hyperlink expression in thymeleaf

The examples are as follows:

<a th:href="@{/user/login}"></a>

<a th:src="@{/user/login}"/>

2. #{}: Message expression or resource expression in thymeleaf

Generally used with th:text a little more, the value taken out by #{} replaces the value in the label, and the value corresponding to #{key}. If there is already a value in the middle of the label, the value retrieved by #{} will overwrite the value in the label

The examples are as follows:

<div th:text="#{user}"> </div>

3. ${}: Variable expression, used to access the variables of the container context, such as domain variables: request domain, session domain

  Think about it carefully, a bit of the meaning of the ${} function in jstl

The examples are as follows:

// 后端代码
session.setAttribute("list",list);

<--取域中的值-->
<div>[[${list}]]</div>

4. *{}: The selection expression is the selected object, not the mapping of the entire environment

   If there is no object, it is basically the same as the variable expression ${}

<p>Name: <span th: text=" *{firstName}" >Sebastian</span>. </p>

<p>Surname: <span th: text=" *{lastName}" >Pepper</span>. </p>

 

 

 

Guess you like

Origin blog.csdn.net/Sunshineoe/article/details/114595194