Strings

Text literals

Now you are looking at a <span th:text="'working web application'">template file</span>.

Number literals

<p>The year is <span th:text="2013">1492</span>.</p>
<p>In two years, it will be <span th:text="2013 + 2">1494</span>.</p>

Boolean literals

<div th:if="${user.isAdmin()} == false"> ...

Note that in the above example, the == false is written outside the braces, and thus it is Thymeleaf itself who takes care of it. If it were written inside the braces, it would be the responsibility of the OGNL/SpringEL engines:

<div th:if="${user.isAdmin() == false}"> ...

Literal tokens

Numeric, boolean and null literals are in fact a particular case of literal tokens. they only allow letters ( A-Z and a-z ), numbers ( 0-9 ), brackets ( [ and ] ), dots ( . ), hyphens ( - ) and underscores ( _ ). So no whitespaces, no commas, etc.

Tokens brauchen nicht zwingend quotes. So kann man zum Beispiel...

<div th:class="content">...</div>

...schreiben, anstelle von

<div th:class="'content'">...</div>

Strings kombinieren

Das Kombinieren von Strings funktioniert wie in Java:

th:text="'The name of the user is ' + ${user.name}"

etwas schöner wird die Syntax, wenn man Literal substitutions verwendet:

Note: only variable expressions ( ${...} ) are allowed inside |...| literal substitutions. No other literals ( '...' ), boolean/numeric tokens, conditional expressions etc. are.

results matching ""

    No results matching ""