title: how to bind list of object for sending post request in spring boot and thymeleaf
body: <p>I have a booking entity and another entity is guest. the relation between them onetomany.</p>
  
  <p>booking entity:</p>
  
  <pre><code>@Entity
  public class Booking {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String nameInit;
      private String firstName;
      private String lastName;
      private String email;
      private String numberInit;
      private String number;
      private boolean status;
  
      @JsonIgnore
      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      private List&lt;Guest&gt;guests;
  </code></pre>
  
  <p>Guest entity:</p>
  
  <pre><code>@Entity
  public class Guest{
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String nameInit;
      private String name;
      private String age;
      private String gender;
  
      @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      @JoinColumn(name = "booking_id")
      private Booking booking;
  </code></pre>
  
  <p>thymeleaf form: </p>
  
  <pre><code>&lt;div class="guest-inputs-wrapper" th:each="item, stat : *{guests}"&gt;
                                                  &lt;div class="row"&gt;
                                                      &lt;div class="col-md-1"&gt;
                                                          &lt;div class="input-field col s12"&gt;
                                                              &lt;div class="guest-number"&gt;
                                                                  Guest &lt;span class="number"&gt;1&lt;/span&gt;
                                                              &lt;/div&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="col-md-2"&gt;
                                                          &lt;div class="input-field col s12"&gt;
                                                              &lt;select name="nameInit" th:field="*{guests[__${stat.index}__].nameInit}" id="g-title-1"&gt;
                                                                  &lt;option value="" disabled selected&gt;Title&lt;/option&gt;
                                                                  &lt;option value="1"&gt;Mr.&lt;/option&gt;
                                                                  &lt;option value="2"&gt;Mrs.&lt;/option&gt;
                                                                  &lt;option value="3"&gt;Ms.&lt;/option&gt;
                                                              &lt;/select&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="col-md-4"&gt;
                                                          &lt;div class="input-field col s12"&gt;
                                                              &lt;input type="text"  class="validate" name="name" th:field="*{guests[__${stat.index}__].name}" id="g-fullname-1" required&gt;
                                                              &lt;label&gt;Full Name&lt;/label&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="col-md-1"&gt;
                                                          &lt;div class="input-field col s12"&gt;
                                                              &lt;input type="text"  class="validate" name="age" th:field="*{guests[__${stat.index}__].age}" id="g-age-1" required&gt;
                                                              &lt;label&gt;Age&lt;/label&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="col-md-3"&gt;
                                                          &lt;div class="input-field col s12"&gt;
                                                              &lt;div class="custom-radio"&gt;
                                                                  &lt;input type="radio" id="m-gender-1" name="gender" th:field="*{guests[__${stat.index}__].gender}" value="Male" checked&gt;
                                                                  &lt;label for="m-gender-1"&gt;Male&lt;/label&gt;
                                                              &lt;/div&gt;
                                                              &lt;div class="custom-radio"&gt;
                                                                  &lt;input type="radio" id="f-gender-1" name="gender" th:field="*{guests[__${stat.index}__].gender}" Value="Female"&gt;
                                                                  &lt;label for="f-gender-1"&gt;Female&lt;/label&gt;
                                                              &lt;/div&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>@GetMapping("/booking/room/{roomId}")
      public String bookingPage(Model model, @PathVariable Long roomId, HttpSession session){
          Booking booking = new Booking();
          booking.getGuests().add(new Guest());
          model.addAttribute("booking", booking);
          return "web/cart";
      }
  
      @PostMapping("/room/save-booking")
      public String createBooking(Model model,@Valid Booking booking, BindingResult result, HttpSession session){
          if (result.hasErrors()){
              model.addAttribute("error", true);
              return null;
          }
          hotelBookingService.save(booking);
          guestService.saveAll(booking.getGuests());
          model.addAttribute("success", true);
          return "redirect:/main";
      }
  </code></pre>
  
  <p>after submitting only one guest information is saved in db with booking information. but i want a list of guest. where is my worng i can't find. why form do not pass list of guest ? please help</p>