SpringBoot使用Thymeleaf填坑

  1. 使用了thymeleaf模板的jquery函数要尽量写在section里面,不然可能没有效果:
<section>
    <script>
        //分页查询
        getExamListByPage = function (currentPage) {
            var pageSize = $("#pageSize").val(); //每页显示条数
            var str = "/exam/charts/getCharts?currentPage="+currentPage+"&pageSize="+ pageSize;
            window.location.href = (str);
        }
    </script>
</section>
  1. html页面调用js文件里的函数,写法尽量为functionName = function (){}形式,其他方式写的话,html页面可能会搜索不到该函数。
  2. button上面添加函数的时候,应该这样写:
//th:onclick="'javascript:functionName('+${corp.id}+')'"
<button id="update-btn" class="btn btn-outline-primary" data-toggle="modal"th:onclick="'javascript:updateRecord('+${grade.gradeId}+','+${grade.flag}+');'">更新记录</button>
  1. Thymeleaf怎么才能原样输出html内容?
//使用 th:utext   这样就可以输出为html了
<p th:utext="${artile.content}">  测试文章摘要 </p>
  1. thymeleaf中的日期格式化的方法:
<span th:text="${#dates.format(startTime,'yyyy-MM-dd HH:mm:ss')}"></span>
  1. thymeleaf / select option list遍历循环:
<select name="items" id="itemId" class="form-control">
            <option th:each="item,itemStat:${itemList}" th:value="${item.itemId}" th:text="${item.name}"></option>
</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值