1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Thymeleaf th:each遍历 th:if th:switch 条件判断 input select radio 回显赋值

Thymeleaf th:each遍历 th:if th:switch 条件判断 input select radio 回显赋值

时间:2018-09-03 18:37:58

相关推荐

Thymeleaf th:each遍历 th:if th:switch 条件判断 input select radio 回显赋值

1. th:each 遍历<!-- 遍历集合,如果被遍历的变量 userList 为 null 或者不存在,则不会进行遍历,也不报错--><tr th:each="user : ${userList}"><!-- 将用户的主键 uId 存在在 name 属性中--><td th:text="${user.uId}" th:name="${user.uId}"></td><td th:text="${user.uName}"></td><!-- 使用dates对象格式化日期--><td th:text="${#dates.format(user.birthday, 'yyyy-MM-dd HH:mm')}"></td><!-- 三运运算判断是否已婚--><td th:text="${user.isMarry}?'是':'否'"></td><td th:text="${user.price}"></td></tr>2. 遍历下拉框<select class="form-control" style="width: 200px;font-size: 16px" id="stationSelect"><option>全区</option><!--后台会传值:model.addAttribute("stationList", stationList); 下拉框所有选项的值--><!--后台会传值:model.addAttribute("stationName", stationName); 用户当前选中的下拉框的值--><option th:each="station : ${stationList}" th:text="${station.name}" th:selected="${stationName} eq ${station.name}">横岗</option></select>3. th:if 条件判断 <!--if属性结果为 true,模板会进行显示--><p th:if="true">th:if="true"</p><!--if属性结果为 false,模板不会进行显示--><p th:if="false">th:if="false"</p><!--后台控制器传出数据:model.addAttribute("isMarry", true);--><p th:if="${isMarry}">已婚</p>4:input 回显赋值<input type="text" class="form-control1" id="name" name="name" th:value="${user.name}">5:select 回显赋值<label class="col-sm-2 control-label">类别</label><div class="col-sm-8"><select name="cId" id="cId" class="form-control1" ><option value="1" th:field="*{book.cId}">目录1</option><option value="2" th:field="*{book.cId}">目录2</option><option value="3" th:field="*{book.cId}">目录3</option><option value="4" th:field="*{book.cId}">目录4</option></select></div>6:radio 回显赋值<label for="isBoy" class="col-sm-2 control-label">是否男生</label><div id="isBoy" class="col-sm-8"><div class="radio-inline"><label><input name="isBoy" type="radio" value="1" th:field="*{book.isBoy}"/> 否</label></div><div class="radio-inline"><label><input name="isBoy" type="radio" value="0" th:field="*{book.isBoy}"/> 是</label></div></div>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。