thymeleaf:日常使用总结
2024-09-22 00:03:56
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>
最新文章
- 学习 opencv---(5) 创建Trackbar(活动条) &;图像对比度,亮度值调整
- js localStorage 设置和取值
- BZOJ2448 : 挖油
- document的createDocumentFragment()方法
- iOS button 里边的 字体的 摆放
- .NET中Debug模式与Release模式
- ubuntu cpus 共享打印
- mysql 导出过长的数字列时变科学计数法问题解决办法
- EF Code First:实体映射,数据迁移,重构(1)
- Mysql SQL优化&;执行计划
- java静态代理与动态代理简单分析
- VMware系统运维(七)vCenter Inventory Server安装
- java 计算器SWT/RAP(版本3)键盘鼠标兼容
- 腾讯云(centos)上安装apache
- 苹果试图做?XCode6 放弃prefix.pch档
- 《解决在Word中为汉子插入拼音及音标的问题》
- 文本三剑客---sed 基础
- vb.net MakeWParam
- DOS简单文件指令
- 前端 html css
热门文章
- 错误	1	未能找到类型或命名空间名称“DataPager”(是否缺少 using 指令或程序集引用?)
- 修改VS 2012调试默认浏览器
- ext Ext.grid.去除右边空白
- 微信接口 output {";errMsg";:";translateVoice:fail, the permission value is offline verifying";}
- springboot-01 helloworld
- 关于PHP建立数据库访问类的封装以及操作php单例模式连接数据库封装类
- oracle行转列函数以及一些窗口函数(PIVOT ,OVER)
- 360doc个人图书馆解决复制问题
- 剑指Offer-表示数值的字符串
- whatis命令,一个非常有用的命令