需要一些建议,我应该如何检索展览清单。

在下面的html模板中,我只记录了一份展览。如果要放置其他行的展览记录,我该如何将它们映射到控制器。

HTML模板

<h3>Exhibit Details</h3>

        <div class="table-responsive">
            <table id="exhibitTable"
                class="table table-bordered table-hover table-striped">
                <thead>
                    <tr>
                        <th>Exhibit Type</th>
                        <th>Description</th>
                        <th>Marking</th>
                        <th>Remarks</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <div class="form-group col-md-3">
                                <div class="cols-sm-10">
                                    <select class="form-control selectpicker cols-md-3"
                                        th:value="${exhibit.exhibitType}" id="exhibitType"
                                        name="exhibitType" roleId="exhibitType">
                                        <option value="">Select Type</option>
                                        <option>Desktop</option>
                                        <option>Laptop</option>
                                        <option>Mobile Device</option>
                                        <option>Portable Storage</option>
                                        <option>Server</option>
                                        <option>Video System</option>
                                        <option>Save As</option>
                                        <option>Others</option>
                                    </select>
                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="form-group col-md-3">
                                <input type="text" name="exhibitDescription"
                                    id="exhibitDescription"
                                    th:value="${exhibit.exhibitDescription}" />
                            </div>
                        </td>
                        <td>
                            <div class="form-group col-md-3">
                                <input type="text" name="exhibitMarking" id="exhibitMarking"
                                    th:value="${exhibit.exhibitMarking}" />
                            </div>
                        </td>
                        <td><div class="form-group col-md-3">
                                <input type="text" name="exhibitRemarks" id="exhibitRemarks"
                                    th:value="${exhibit.exhibitRemarks}" />
                            </div></td>

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


控制者

@RequestMapping(value = "/register", method = RequestMethod.POST)
    public String registerIncidentPost(@ModelAttribute("incident") Incident incident,
            @ModelAttribute("exhibit") Exhibit exhibit, Principal principal) throws Exception {

        long year = Calendar.getInstance().get(Calendar.YEAR);
        incident.setIncidentYear(year + "");

        Long refNo = incidentService.findMaxRefNoCurrentYear(year + "");
        if (refNo == null)
            refNo = (long) 1;
        else
            refNo += 1;
        incident.setIncidentRefNo(refNo);

        incident.setIncidentStatus(Incident.INCIDENT_REGISTERED);

        incident.setIncidentOpeningTimestamp(new Date());

        User user = userService.findByUsername(principal.getName());
        incident.setIncidentCreatedBy(user);

        incidentService.createIncident(incident);

            exhibitService.createExhibit(exhibit);

        return "redirect:/incident";
    }


我试图将以下内容添加到我的模板中
<tr data-th-each="exhibit:${exhibitList}">

然后将以下内容发送给我的控制器
@ModelAttribute("exhibitList") ArrayList<Exhibit> exhibitList

但没有用。

提前致谢。

最佳答案

由于您未指定,因此我只能假设这是vb.net。您需要将完整的数据集传递到页面。数据集中的每个项目都是模型的一个预加载实例。然后,您可以对页面本身上的每个循环执行a并动态生成html。希望这可以帮助。

10-02 09:59