如何使用百里香叶获取列表中的列表数据?

时间:2017-03-30 11:34:19

标签: java html spring-boot thymeleaf

我有两个实体参与者和XrayFieldRadiology。他们有关系。因此,每当我选择参与者时,也会选择相关的XrayFieldRadiology。现在我需要在我的桌子和表格上显示所有这些数据库。

我的html文件看起来像这样。

Xraystatusform.html

    <div class="box-body" >
                        <span class="successMessage" th:text="${dataSuccess}" style="color: green; align-self:flex-end"></span>
                        <table id="example1" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>Person Id</th>
                                <th>First Name</th>
                                <th>Last Name</th>
                                <th>Age</th>
                                <th>Sex</th>
                                <th>District</th>
                                <th>VDC/MUNICIPAL</th>
                                <th>Ward No.</th>
                                <th>Xray Status</th>
                                <th>Remarks</th>
                                <th>Actions</th>
                            </tr>
                            </thead>
                            <tbody  th:each="persons : ${part}">
                                <form  method="post" th:action="@{/xraystatus(id=${persons.id})}" enctype="multipart/form-data" id="form1">
                                    <td th:text="${persons.id}" id="xrayid"></td>
                                    <td th:text="${persons.name}"></td>
                                    <td th:text="${persons.lastName}"></td >
                                    <td th:text="${persons.age}"></td>
                                    <td th:text="${persons.sex}"> </td>
                                    <td th:text="${persons.district}"></td>
                                    <td th:text="${persons.district}"></td>
                                    <td th:text="${persons.wardNo}"></td>

                                    <td>
                                        <div class="checkbox"  >
                                            <select name="xraystatus" onchange="yesnoCheck(this);" style="width:61px"  >
                                                <!--<option th:each="xraydata:${xraydata}" th:text="${xraydata.xrayStatus}"></option>-->
                                                <option value="">Select</option>
                                                <option value="1">Yes</option>
                                                <option value="0">No</option>
                                                <option value="2">Possible</option>
                                                <option value="3">Exempted</option>
                                            </select>
                                        </div>
                                    </td>


                                    <td >
                                        <!--<div id="ifYes6" style="display:none; height:30px" >-->
                                            <input type="text" name="remarks"  >
                                        <!--</div>-->
                                    </td>
                                    <td><button type="submit" class="btn btn-success" >Submit</button> </td>
                                </form>

                            </tbody>
                        </table>
                    </div>

我的控制器会返回这样的数据。

data picture

在我的输入字段上备注我需要加载备注数据,例如blindman。并在xraystatus例如0,1(根据数据库)。

到目前为止,我的表格看起来像这样。

table

所以通过使用thymeleaf我怎样才能访问列表中的列表?

1 个答案:

答案 0 :(得分:0)

如果我正确地阅读您的数据,它应该像以下一样简单:

<input type="text" name="remarks" th:value="${persons.xrayFieldRadiology != null ? persons.xrayFieldRadiology.remarks : ''}" />