发送第二个对象的处理器问题执行期间出错

时间:2019-11-14 00:02:43

标签: java spring thymeleaf

我正在尝试创建一个表单,我们在其中填写客户字段并分配选择用户(该用户已经存在于数据库中),问题是无法发送和下载用户。 我要提示或指导

<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="*{user}" name="user"  >
                                        <option> -- </option>
                                        <option  th:each=" users : ${patrons}"
                                                 th:value="${users.UserId}"
                                                 th:utext="${users.lastName}"/>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-submit" id="przyciski">
                            <input type="submit" value="Dodaj" class="submit" id="submit" name="Dodaj" />
                            <input type="submit" value="Wyjdź" class="submit" id="reset" name="Wyjdź" />
                        </div>
                    </form>

控制器

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

    return "dodaj";
}
@ModelAttribute("patrons")
List<User> allUsers() {
    return userService.getAllUser();
}

错误错误完全适用于以下行:html中 org.thymeleaf.exceptions.TemplateProcessingException:执行处理器'org.thymeleaf.spring5.processor.SpringSelectFieldTagProcessor'时出错(模板:“ dodaj”-第178行,列50)

0 个答案:

没有答案