- 使用了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>
- html页面调用js文件里的函数,写法尽量为functionName = function (){}形式,其他方式写的话,html页面可能会搜索不到该函数。
- 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>
- Thymeleaf怎么才能原样输出html内容?
//使用 th:utext 这样就可以输出为html了
<p th:utext="${artile.content}"> 测试文章摘要 </p>
- thymeleaf中的日期格式化的方法:
<span th:text="${#dates.format(startTime,'yyyy-MM-dd HH:mm:ss')}"></span>
- 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>