4.4 thymeleaf使用补充

1. 转义字符的使用

th:text="${#dates.format(ruleSeasonalRestrictPo.beforeDate,'yyyy-MM-dd''T''HH:mm:ss')}"

效果:2019-06-28T10:08:32,使用转义字符可以使得时间格式里面的字符T不被当做格式字符而匹配

2. 判断一个对象是否为空,不为空的话获取属性的值

th:if="${ruleSeasonalRestrictPo?.tag == 2}"

 3. 动态改变style样式

// 显示隐藏
<button th:style="'display:'+ @{(${idEdit} ? 'none' : 'inline-block')}+''">审核通过</button>
// 是否可用
<input type="text" name="rMK2Content" value="" th:disabled="${isEdit}">
原文地址:https://www.cnblogs.com/shiyun32/p/11101176.html