title: Thymeleaf Map Form Binding
body: <p>db.html</p>
  
  <pre><code>&lt;div th:each="pr, stat: *{mergeMap}"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input type="text" name="key" th:value="${pr.key}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="value" th:value="${pr.value}" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>On submitting this input, i always get mergeMap to be empty at the Spring Controller. What should be done to get the value of mergeMap?</p>
  
  <p>Controller.java</p>
  
  <pre><code>@RequestMapping(value = "/shot")
      public String saveMergeProducts(@ModelAttribute(value="prod") MergedProductInfoDTO prod, BindingResult bindingResult, 
              Model model, HttpServletRequest request) {
          System.out.println(prod.toString());
          return "forward:/backoffice/db";
      }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;form action="#" th:action="@{shot}" method="POST" th:object="${prod}"&gt;
              &lt;tr&gt;
              &lt;td&gt;&lt;span th:text="${index.index}"&gt;&lt;/span&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="id" th:value="*{id}" th:readonly="readonly" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="categoryName" th:value="*{categoryName}" th:readonly="readonly" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="subCategoryName" th:value="*{subCategoryName}" th:readonly="readonly" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="productBrand" th:value="*{productBrand}" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="productSubBrand" th:value="*{productSubBrand}" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="series" th:value="*{series}" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="model" th:value="*{model}" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="7"&gt;
                              &lt;tr&gt;
                                  &lt;th&gt;KEY&lt;/th&gt;
                                  &lt;th&gt;VALUE&lt;/th&gt;
                              &lt;/tr&gt;
                              &lt;div th:each="pr, stat: *{mergeMap}"&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;&lt;input type="text" name="mergeMapKey" th:value="${pr.key}" /&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;input type="text" name="mergeMapValue" th:value="${pr.value}" /&gt;&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/div&gt;
                          &lt;/table&gt;
                      &lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="tags" th:value="*{tags}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="submit" value="Submit" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  </code></pre>