文本連接配接
無論是什麼形式的文本:字面量'...',變量表達式求值或消息表達式求值的結果,都可以用'+'進行連接配接
th:text="'The name of the user is ' + ${user.name}"
1
文字替換
文字替換可以友善的格式化包含變量的字元串,而無需使用文本連接配接'...' + '...'。
文字替換的文法為| text substituion demo ${varialble} |
<span th:text="|Welcome to our application, ${user.name}!|">
1
等效于
<span th:text="'Welcome to our application, ' + ${user.name} + '!'">
1
文字替換本身可以和與其他表達式聯合使用
<span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">
1
但是|...|本身中隻能包括變量表達式${},不能有其他表達式,比如文本字面量'...', 條件表達式等。