thymeleaf 簡單應用

th:switch 應用html

<th:block th:switch="${mapResult.bidType}">
    <th:block th:case="'1'">
        <head th:replace="common/include-header :: header (${bidProjectTypeMap[mapResult.bidProjectType]}+'公告變動')"/>
    </th:block>
    <th:block th:case="'2'">
        <head th:replace="common/include-header :: header ('投標邀請變動')"/>
    </th:block>
    <th:block th:case="*">
        <head th:replace="common/include-header :: header (${bidProjectTypeMap[mapResult.bidProjectType]}+'公告變動')"/>
    </th:block>
</th:block>

判斷對象屬性是否存在spa

<p class="project-name" th:if="${#maps.containsKey(mapResult, 'bidType')}">
<span th:text="${mapResult.bidType}"></span>
</p>
另
// 判斷對象的屬性是否存在
var userMobile = [[${user?.mobile}]];

頁面定義變動 th:withcode

<html xmlns:th="http://www.thymeleaf.org" th:with="COMPANY_NAME='聯成化學科技股份有限公司'">
相關文章
相關標籤/搜索