thymeleaf常用语法

转自:https://segmentfault.com/a/1190000017563310



<!--如果msg的值为空,则不显示消息-->
<p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>

代码复用;提取公共页面 th:insert或者th:replace:~{--::--}--页面下的--组件
th:fragment="sidebar"
th:replace="~{commons/commons::sidebar(传递的参数)}"commons文件夹下的commons.html中的sidebar组件,
如果要接收参数,可以直接使用()传参,接收判断即可
原文地址:https://www.cnblogs.com/bxbo/p/13476544.html