title: Spring MVC controller doesn't handle submit from Thymeleaf
body: <p>I created simple Thymeleaf form template for user registration.
  When I hit submit form button, POST request is sent (as I see from browser log), but it never handled by saveRegistration controller method, annotated with (method = RequestMethod.POST)</p>
  
  <p>Spring version 4.2.2 , Spring security 4.0.2, Spring boot starter 1.2.7
  Model object uses Hibernate validators (if it make sense)</p>
  
  <p>Controller code:</p>
  
  <pre><code>package org.vmtest.web.controller;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.vmtest.web.model.User;
  
  import javax.validation.Valid;
  import java.util.*;
  
  /**
   * Created by victor on 24.10.15.
   */
  @Controller
  @RequestMapping("/register")
  public class RegistrationController {
  
      @RequestMapping(method = RequestMethod.GET)
      public String newRegistration(ModelMap model) {
          User user = new User();
          model.addAttribute("user", user);
          return "register";
      }
  
      @RequestMapping(method = RequestMethod.POST)
      public String saveRegistration(@Valid User user, BindingResult result, ModelMap model){
  
          if(result.hasErrors()) {
              return "register";
          }
  
          model.addAttribute("success", "Dear "+ user.getFirstName()+" , your Registration completed successfully");
          return "redirect:/login";
      }
  
      @ModelAttribute("countries")
      public Map&lt;String, String&gt; initializeCountries() {
  
          Map&lt;String, String&gt; countries = new TreeMap&lt;&gt;();
  
          String[] locales = Locale.getISOCountries();
          for (String countryCode : locales) {
              Locale obj = new Locale("", countryCode);
              countries.put(obj.getDisplayCountry(), obj.getCountry());
          }
  
          return countries;
      }
  
  }
  </code></pre>
  
  <p>Thymeleaf template:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
        xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"&gt;
  &lt;head&gt;
      &lt;style&gt;
          form {
              position: absolute;
              top: 20%;
              left: 40%;
              margin-top: -50px;
              margin-left: -50px;
              width: 300px;
              height: 100px;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;
      &lt;form action="#" th:action="@{/register}" th:object="${user}" method="post"&gt;
          &lt;div&gt;
              &lt;h2&gt;New user registration&lt;/h2&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;table style="width:300px"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Login&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{userName}" name="username"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Password&lt;/td&gt;
                      &lt;td&gt;&lt;input type="password" th:field="*{password}" name="password"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;First Name&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{firstName}" name="firstname"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Last Name&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{lastName}" name="lastname"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;E-Mail&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{email}" name="email"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Street address&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{street}" name="street"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;City&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{city}" name="city"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;State/province&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{state}" name="state"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Country&lt;/td&gt;
                      &lt;td&gt;
                          &lt;select th:field="*{country}"&gt;
                              &lt;option th:each="sopt:${countries.entrySet()}"
                                      th:value="${sopt.value}" th:text="${sopt.key}"&gt;Japan&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Post code&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{postCode}" name="postcode"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Phone number&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" th:field="*{phone}" name="phone"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr&gt;
                      &lt;td&gt;Don't have account?&lt;/td&gt;
                      &lt;td&gt;&lt;button type="submit"&gt;Register&lt;/button&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>