I want to deliver the entire object from html to the controller
Controller:
@RequestMapping(method = RequestMethod.GET) public String get(){ Info info = new Info(); info.setTitle("Hello"); model.addAttribute("infos", Collections.singleton(info)); return "info-page"; } @RequestMapping(method = RequestMethod.POST, value = "show-all") public String showAllInfoObject(@ModelAttribute("info") Info info){ // info has null values! } HTML
<li th:each="info : ${infos}"> <span th:text="${info.title}">webTitle</span>. <form th:action="@{'/show-all}" method="post"> <input type="hidden" name="result" th:field="*{info}" /> <input type="submit" value="show detalis" /> </form> </li> However, the controller gets an empty object. Interestingly, when I provide only String "title", it gets the correct result in the controller.
How to deliver correctly the whole object from HTML?