title: Spring MVC - HTTP status code 400 (Bad Request) for missing field when submitting form with dropdown
body: <p>I'm using spring mvc with thymeleaf to save a form with a dropdown value. The problem is when saving, I get the error 400 bad request only when I append the foreign key field in the form as a dropdown with <code>th:field="studentTypeCode"</code>.</p>
  
  <pre><code>&lt;select id="typeSelect" class="text_box" th:field="*{studentTypeCode}"&gt;
      &lt;div th:each="studentTypeCode : ${studentTypeCodes}" th:remove="tag"&gt;
          &lt;option th:value="${studentTypeCode.typeId}" th:text="${studentTypeCode.typeName}" /&gt;
      &lt;/div&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Student.java</p>
  
  <pre><code>public class Student{
      private String name;
      //... other fields
      //..
      StudentTypeCode studentTypeCode;
  
      //getters and setters
  }
  </code></pre>
  
  <p>And in the controller I get the Student object using the <code>th:object</code> with the </p>
  
  <p><code>@ModelAttribute Student student</code> param. Saving the form throws me 400 bad request since the field <code>studentTypeCode</code> is not correctly sent in the request.</p>