主题叶循环使用 th:each



我正在尝试浏览数据库中的列表并将其发布在html表单上。我让它工作的唯一方法是使用以下代码:

<tr th:each="customer: ${rxReqBean.iCustomer}">     
<p type="hidden" th:text="'First Name: ' + ${rxReqBean.iCustomer.get(0).firstName}"/></p>

如图所示,我一遍又一遍地得到相同的名字。有没有办法更改它以返回数据库中的每个名字?数据库页面是 iCustomer 对象

问题是你总是通过使用get(0)来引用列表的第一个客户${rxReqBean.iCustomer.get(0).firstName},你必须改用你的迭代变量:${customer.firstName}

最新更新