其他分享
首页 > 其他分享> > Thymeleaf:直接显示变量内容,不带标签

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

作者:互联网

方法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>

标签:不带,name,标签,转义,Thymeleaf,html,user,th,Hello
来源: https://www.cnblogs.com/wbyixx/p/14472796.html