title: Spring Thymeleaf pass object attribute to href button submit
body: <p>I'm trying to do a form action where I show selected lists for each of some grouped values. After the user chooses a value in one of these lists I want to put the name of this object into a button link as a parameter but the parameter values are empty. I don't know how can I do it.</p>
  
  <p>Here is my code for that:</p>
  
  <p>In my controller:</p>
  
  <pre><code>@RequestMapping(value="/teacher/depts", method=RequestMethod.GET)
  public String depts(Model model) {
      model.addAttribute("deptsfields", fieldOfStudyService.findAllFieldsForAllDepartments());
      model.addAttribute("field", new FieldOfStudy());
  
      return "teacher/depts";
  }
  
  @RequestMapping(value="/deptsfields", method=RequestMethod.POST)
  public String deptsfields(@ModelAttribute(value="field") FieldOfStudy field) {
      return "teacher/depts";
  }
  </code></pre>
  
  <p>And my html page:</p>
  
  <pre><code>&lt;form action="#" th:action="@{/deptsfields}" th:object="${field}" method="post"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;th&gt;Wydział&lt;/th&gt;
              &lt;th&gt;Kierunek&lt;/th&gt;
          &lt;/tr&gt;
  
          &lt;tr th:each="entry : ${deptsfields}"&gt;
              &lt;td th:text="${entry.getKey().details.departmentFullName}"
                  th:value="${entry.getKey().details.departmentFullName}"
                  th:field="*{details.department.details.departmentFullName}"&gt;&lt;/td&gt;
              &lt;td&gt;
                  &lt;select id="fieldslist" class="form-control" th:field="*{details.fieldOfStudyName}"&gt;
                      &lt;option selected="selected" value=""&gt;Wybierz...&lt;/option&gt;
                      &lt;option th:each="field : ${entry.getValue()}" th:value="${field.details.fieldOfStudyName}" th:text="${field.details.fieldOfStudyName}"&gt;&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
  
          &lt;/tr&gt;
      &lt;/table&gt;
  
      &lt;a th:href="@{/teacher/groups(field=${field.details.fieldOfStudyName}, dept=${field.details.department.details.departmentFullName})}" class="btn btn-info" role="button"&gt;Dalej&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>After click the button I'm redirected to this page:</p>
  
  <pre><code>http://localhost:8080/teacher/groups?field={here should be name but is empty}&amp;dept={here should be name but is empty}
  </code></pre>
  
  <p>What I'm doing wrong?</p>