gpt4 book ai didi

java - 如何从对象列表中选择一个对象

转载 作者:行者123 更新时间:2023-12-01 21:17:39 26 4
gpt4 key购买 nike

HTML

 <form th:object="${klient}" th:action="@{/osoba}" method="post">
<div class="form-row">
<div class="form-group col-md-4">
<label >Imię</label>
<input type="text" class="form-control" th:field="*{imie}" >
</div>

<div class="form-group col-md-4">
<label >Nazwisko</label>
<input type="text" class="form-control" th:field="*{nazwisko}" >
</div>
<div class="select-list" id="selectlist">
<select th:field="*{UserId}" >
<option> -- </option>
<option th:each=" users : ${user}"
th:value="${users.UserId}"
th:utext="${users.lastName}"/>
</select>
</div>

鳕鱼

    @RequestMapping (value = "/osoba", method = RequestMethod.POST)
public String dodaj (Klient klient){
System.out.print(klient);
return "redirect:/osoba";
}
@RequestMapping (value = "/dodaj" , method = RequestMethod.GET)
public String tworz (Model model){
model.addAttribute("klient" , new Klient());

List<User> lista = userService.getAllUser();
model.addAttribute("user" , lista);

return "dodaj";
}

我想创建一个表单,让他填写客户的字段并为其分配一个现有用户。问题是我无法获取所选的用户 ID。

我收到一条有关第一个选择的消息

Error during execution of processor 'org.thymeleaf.spring5.processor.SpringSelectFieldTagProcessor

最佳答案

错误消息显示名为 uzytkownik 的属性存在问题,但我在模板中的任何位置都没有看到该属性。当然,您没有包含完整的模板,所以我只能说问题来自其他地方......显然来自第 178 行。

关于java - 如何从对象列表中选择一个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58861646/

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