thymeleaf

【一】三元運算符

  1. select中:less

    <select class="form-control" id="mt" name="noticetype">
            <option value="0">--請選擇--</option>
            <option th:each = "noticetype : ${noticetypeList}" th:selected="${noticetype.id} eq ${noticemodel.noticetype} ? true : false" th:value = "${noticetype.id}">
              <span th:text="${noticetype.name}"></span>
            </option>
        </select>
  2. class中spa

    <a href="/" th:class="@{(${category}  eq  'home' ? 'active-class' : '')}" class="active-class">首頁</a>
  3. text中code

    <td th:text="${bidAnnounceDO.f eq 1 ? '已發佈' : '未發佈'"}></td>
    //若是有多個用()括起來,如:
    <td th:text="${bidAnnounceDO.f eq 1 ? '已發佈' : (${bidAnnounceDO.f} eq 2 ? '考慮中' : '未發佈''')}"></td>

【二】多條件判斷

th:if="${bidSuppreDO.result eq 0 && bidSuppreDO.f eq 0}"

【三】關係運算符

gt:great than(大於)>
    ge:great equal(大於等於)>=
    eq:equal(等於)==
    lt:less than(小於)<
    le:less equal(小於等於)<=
    ne:not equal(不等於)!=
相關文章
相關標籤/搜索