Я имею дело с сохранением сущности из формы тимьяфа в базу данных.
Мой текущий подход.
Форма Thymeleaf в register.html
<form action="save" th:method="post" th:action="@{save}" th:object="${customer}">
<input type ="text" th:field="*{firstName}" placeholder="First Name" /><br />
<input type ="text" th:field="*{lastName}" placeholder="Last Name" /><br />
<input type="email" th:field="*{emailAddress}" placeholder="Email" /><br />
<input type="password" th:field="*{password}" placeholder="Password" /><br />
<input style="text-align: center" type="submit" value="Register" /> </form>
Методы контроллера:
@RequestMapping("/home")
public String home(Model model){
model.addAttribute("customer", new Customer());
return "register";
}
@RequestMapping("save")
public String save(@ModelAttribute(value = "customer") Customer customer) {
customerRepository.save(customer);
return "saved";
}
Существует проблема с привязкой данных, как показано на скриншоте
![database results](https://i.stack.imgur.com/sLtZ4.jpg)