表单常用赋值方法
1. 代码块插入
- th:include
- th:insert
- th:replace
<div th:fragment="demoFrag" id="frag">
<span style="color: red">演示文字</span>
</div>
<div th:include="~{this::demoFrag}">
<span style="color: red">演示文字</span>
</div>
<div th:insert="~{this::demoFrag}">
<div id="frag">
<span style="color: red">演示文字</span>
</div>
</div>
2.form表单赋值
- th:id
- th:value
- th:name
- th:class
- …
<a href="javascript:void (0)" th:id="${person.id}" th:text="${person.name}" th:data-age="${person.age}" onclick="oncl1(this.getAttribute('data-age'))"></a>
<a th:onclick="|oncl1('${person.age}')|"></a>
<input th:value="${person.age}" readonly>
3.循环遍历
<ul>
<li th:each="item:${people}" th:class="${itemStat.even ? 'odd' :'even'}" th:text="|${item.name}:${item.age}岁3333|"></li>
</ul>
4.js中使用model内的传值
<script th:inline="javascript">
var people = [[${people}]] ;
console.log(people);
</script>