thymeleaf下拉框从后台动态回显选中

 
<select name="supplierCode" lay-search="">
                            <option value="">请选择供</option>
                            <option th:selected="${res.supplierCode  eq supplier.supplierCode}" <!--回显选中-->
                            th:each="supplier : ${insuranceInfoDto.upiInsuranceSupplierDtoList}"<!--循环遍历集合-->
th:value="${supplier.supplierCode}" th:text="${supplier.supplierName}"></option>
                        </select>

说明1:th:each、th:value、th:text代码部分为下拉框数据回显。

说明2:th:selected代码部分为下拉框选中

另外,在小小介绍一下thymeleaf:
优秀的模板引擎,有网无网的环境下都能运行,可在浏览器端直接查看静态页面,也可以通过服务器查看带数据的动态页面;当有数据返回到页面时,thymeleaf标签会动态的替换掉静态内容,是页面动态显示。
开箱即用。
提供spring标准方言和一个springmvc完美集成的可选模块,可以快速实现表单绑定、属性编辑器等功能。
变量表达式${}
选择(星号)表达式*{}
国际表达式#{}
URL表达式@{}

加入th:标签即表示动态显示内容

猜你喜欢

转载自my.oschina.net/u/3632227/blog/2936101
今日推荐