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>
  • 相关阅读:
    tableView小细节
    iOS5 切换中文键盘时覆盖输入框的解决方案
    NSBundle读取txt文件,图片,plist
    iOS OC 字符串处理
    图片拉伸 几种方式
    UIAlertView小结
    新来报道
    VC6.0之Debug调试总结
    关于C++中的临时对象问题
    与临时对象的斗争(下)
  • 原文地址:https://www.cnblogs.com/huiy/p/9001080.html
Copyright © 2011-2022 走看看