thymeleaf 基本常识

1、传参

th:href="@{/console/createBilling(appKey=${appInfoForm.appKey})}"

2、if判断,并连接用and

th:if="${appInfoForm.billingId ne 0 and appInfoForm.billingPayed eq false}"
3、日期的格式化

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

4、单击事件

th:οnclick="'javascript:deleteBilling(\''+${appInfoForm.billingId}+'\',\''+${appInfoForm.appKey}+'\');'"
其中deleteBilling是在js中定义好的方法。

5、html页面中的js必须用/*<![CDATA[*/ this is JavaScript code /*]]>*/包裹,否则会出现些许问题,比如js中&符号的出现会导致页面运行出错。

<script type="text/javascript">
/*<![CDATA[*/
function themPage(value,type){
   alert(value);
}
function themPage2(value,type){
   alert(type);
}
/*]]>*/
</script>

6、循环select 的option项

<select class="form-control" id="slaId" th:field="*{slaId}">
	<option value="0">请选择</option>
	<option th:each="slaItem : ${slaItems}" th:value="${slaItem.id}" th:text="${slaItem.name}">Options</option>
</select>

7、按原样输出带有html标签的字符

使用th:utext就可以,假设msg是java后端传过来的内容是"<br/>"的session变量,那么下面的语句中将会在span标签里面进行一次换行:

<span th:utext="${session.msg}"></span>

8、赋值判断

<li>支持自定义知识库:<strong th:text="${slaItem.supportCustomize eq 1}?'是':'否'"></strong></li>

9、判断集合长度是否是0

th:if="${#lists.size(appInfoFormList)} eq 0"


  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值