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>