gpt4 book ai didi

java - 从数据表中检索输入

转载 作者:行者123 更新时间:2023-12-02 06:25:37 26 4
gpt4 key购买 nike

需要一些建议,我应该如何检索展品列表。

在下面的 html 模板中,我只放置了一条展览记录。如果我要放置额外的展览行/记录,我该如何将它们映射到 Controller 。

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>

Controller

@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}">

以及我的 Controller 的以下内容 @ModelAttribute("exhibitList") ArrayList<Exhibit> exhibitList

但没有成功。

提前致谢。

最佳答案

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

关于java - 从数据表中检索输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55788840/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com