Я новичок в thymeleaf
и Spring-Boot
, я следовал этому учебнику , чтобы создать форму отправки. Я сделал то же самое, но получаю следующее исключение:
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'conjugation' available as request attribute
Может кто-нибудь сказать мне, что не так в моем коде, зная, что это мой Conjugation
класс
public class Conjugation {
private String v;
public String getV() {
return this.v;
}
public void setV(String v) {
this.verb = v;
}
}
Это то, что я использовал в своем контроллере
//The Controller
@GetMapping("/conjugate")
public String vForm(Model model) {
model.addAttribute("conjugate", new Conjugation());
return "conjugate";
}
@PostMapping("/conjugate")
public String vbSubmit(@ModelAttribute Conjugation conjugate) {
System.out.println("-->"+conjugate.getV());
return "index";
}
И это мой index.html
файл:
<form action="#" th:action="@{/conjugate}" th:object="${conjugation}" method="post">
<div class="cell">
V
</div>
<div class="cell">
<input class="cell" type="text" th:field="*{v}" />
</div>
<div class="cell">
<input type="submit" value="Submit" />
</div>