zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    java继承
    java构造器
    java接口
    java 泛型详解---转载
    java竞争抢答器
    java并发资源访问_01
    java多线程数字加减
    java多线程计算机流水线模型
    Java并发编程:Callable、Future和FutureTask---转载测试
    购物车
  • 原文地址:https://www.cnblogs.com/huiy/p/9001080.html
Copyright © 2011-2022 走看看