【thymeleaf】th:text、[[]]、th:utext、[()]输出变量
生活随笔
收集整理的這篇文章主要介紹了
【thymeleaf】th:text、[[]]、th:utext、[()]输出变量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
- thymeleaf 3.0
含義
th:text 輸出的結果將被 HTML-escaped
th:utext 輸出的結果將不被 HTML-escaped
[[...]] 是 inline 表達式,等價于 th:text
[(...)] 是 inline 表達式,等價于 th:utext
th:text
<p th:with="msg='This is <b>great!</b>'" th:text="${msg}">text</p>輸出:
<p>This is <b>great!</b></p>th:utext
<p th:with="msg='This is <b>great!</b>'" th:utext="${msg}">text</p>輸出:
<p>This is <b>great!</b></p>[[…]]
<p th:with="msg='This is <b>great!</b>'">The message is "[(${msg})]"</p>輸出:
<p>The message is "This is <b>great!</b>"</p>[(…)]
<p th:with="msg='This is <b>great!</b>'">The message is "[(${msg})]"</p>輸出:
<p>The message is "This is <b>great!</b>"</p>在 javascript 中使用
<script th:inline="javascript">a=[[${"123"}]];b=[(${"123"})];c=[[${123}]];d=[(${123})]; </script>結果:
<script th:inline="javascript">a="123";b=123;c=123;d=123; </script>參考
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#unescaped-text
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#expression-inlining
總結
以上是生活随笔為你收集整理的【thymeleaf】th:text、[[]]、th:utext、[()]输出变量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑开机锁怎么解?
- 下一篇: 机械键盘的修理方法是什么