title: Thymeleaf - How to send an object (with child object) from form back to the Controller
body: <p>I'am trying to "send" a "complex" object from a thymeleaf form back to the controller.
  I found this minimal example (<a href="https://stackoverflow.com/questions/17669212/send-datas-from-html-to-controller-in-thymeleaf">Send datas from html to controller in Thymeleaf?</a>), which does basically the same thing (Works perfectly). The only difference is, that their object has a String attribute instead of an other object.</p>
  
  <p>But once I replace the String Attribute with the bar object, the bar object is always null, when submitting the form. 
  Is submitting nested objects even possible?</p>
  
  <p>Objects</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Foo {
      private Bar bar;
  
      public Bar getBar() {
          return bar;
      }
  
      public void setBar(Bar bar) {
          this.bar = bar;
      }
  }
  
  public class Bar {
  
      private String id;
  
      public Bar(String id) {
          this.id = id;
      }
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre class="lang-java prettyprint-override"><code>@RequestMapping(value = "/showForm", method= RequestMethod.GET)
  public String showForm(Model model) {
      Foo foo = new Foo();
      foo.setBar(new Bar("test"));
      model.addAttribute("foo", foo);
      return Pages.TEST;
  }
  
  @RequestMapping(value = "/processForm", method=RequestMethod.POST)
  public String processForm(@ModelAttribute(value="foo") Foo foo) {
      ...
      return Pages.TEST;
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="#" th:action="@{/processForm}" th:object="${foo}" method="post"&gt;
      &lt;input type="text" th:field="*{bar}"/&gt;
      &lt;input type="submit"/&gt;
  &lt;/form&gt;
  </code></pre>