Thymeleaf:直接显示变量内容,不带标签

FLowUs邀请链接:https://flowus.cn/login?code=AXNU63
FlowUs邀请码:AXNU63


RoamEdit 感兴趣的可以点击下面的连接进行注册 -
邀请码:ycgca02
RoamEdit是国内首款双向链接大纲工具,它能轻松地将你的知识建成一个知识网络,学过的知识很容易就能被应用起来 https://roamedit.com/?invite=ycgca02


方法1:使用 th:block

<th:block th:text="${msg}" />

方法2:使用 inline

<title>[[${msg}]] - 服务器错误。</title>

Hello, [[${user.name}]]!   //[[]]写法会html转义
Hello, [(${user.name})]!   //[()]写法不会html转义

参考:https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#inlining

方法3:使用 th:remove

<span th:text="${msg}" th:remove="tag"></span>
posted @ 2021-03-03 10:00  wbytts  阅读(472)  评论(0编辑  收藏  举报