• thymeleaf:日常使用总结


    1.th:href

    获得当前的根路径 th:href="@{/}"

    2.select输出并自动选中

    <select class="form-control select2" id="stage2CoachID" name="stage2CoachID"
         th:value="${class.stage2CoachID}">
         <option value="">请选择</option>
         <th:block th:each="entityCoach : ${listEntityCoach}">
             <option th:value="${entityCoach.coachID}" th:text="${entityCoach.userName}"
                     th:selected="${entityCoach.coachID == class.stage2CoachID}">教练名称</option>
         </th:block>                               
    </select>

    3.map方法

    判断是否有指定key值时,必须用get方法,不能用[]

    正确写法:

    th:class="${mapTeachTrain.get(key)}!=null?${mapTeachTrain.get(key)}:'book'"

    错误写法

    th:class="${mapTeachTrain[key]}!=null?${mapTeachTrain[key]}:'book'"

    key是定义的一个变量,完整代码:

    <td th:with="key=${car.carID+'-'+car.coachID+'-'+detail.startTime+'-'+detail.endTime}" 
        th:class="${mapTeachTrain.get(key)}!=null?${mapTeachTrain.get(key)}:'book'"
        th:data="${key}" th:id="${car.carID+detailStat.index}"></td>
  • 相关阅读:
    CFS 调度器
    RCU
    linux cfs 负载均衡
    wait_event_interruptible_timeout
    算法(13)Contiguous Array
    算法(12)Pascal's Triangle II
    算法(12)Best Time to Buy and Sell Stock II
    算法(11)Find All Duplicates in an Array
    算法(10)Subarray Sum Equals K
    算法(9)Find the Duplicate Number
  • 原文地址:https://www.cnblogs.com/huiy/p/9001080.html
Copyright © 2020-2023  润新知