title: Spring MVC is confusing get and post methods with the same request mapping
body: <p>I have a login controller that I've mapped the "/login" path to two different methods.  One will be called for get and the other for post.</p>
  
  <pre><code>@RequestMapping(value = "/login", method = RequestMethod.GET)
  public String login(Model model){
      LoginDto loginDto = new LoginDto();
      model.addAttribute("loginDto", loginDto);
      return "home/login";
  }
  
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public String doLogin(@Valid LoginDto loginDto, BindingResult bindingResult){
      if(bindingResult.hasErrors()){
          return "home/login";
      }
      return "redirect:/";
  }
  </code></pre>
  
  <p>I have the thymeleaf form</p>
  
  <pre><code>&lt;form method="POST" th:action="@{/login}" th:object="${loginDto}"&gt;
      &lt;div class="form-group-row"&gt;
          &lt;label&gt; Email &lt;/label&gt;
          &lt;input type = "text" th:field = "*{email}"/&gt;
          &lt;span th:if="${#fields.hasErrors('email')}" th:errors = "*{email}"&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label&gt; Password &lt;/label&gt;
          &lt;input type = "text" th:field = "*{password}"/&gt;
      &lt;/div&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When enter data and click submit the method with the GET request is called.  I know this from inserting breakpoints in both methods.  Also the url now has a ?errors at the end of it.  I've also changed the url mapping to the second method to "doLogin" like this</p>
  
  <pre><code>@RequestMapping(value = "/dologin", method = RequestMethod.POST)
  public String doLogin(@Valid LoginDto loginDto, BindingResult bindingResult){
      if(bindingResult.hasErrors()){
          return "home/login";
      }
      return "redirect:/";
  }
  </code></pre>
  
  <p>and changed the form to this</p>
  
  <pre><code>&lt;form method="POST" th:action="@{/dologin}" th:object="${loginDto}"&gt;
      &lt;div class="form-group-row"&gt;
          &lt;label&gt; Email &lt;/label&gt;
          &lt;input type = "text" th:field = "*{email}"/&gt;
          &lt;span th:if="${#fields.hasErrors('email')}" th:errors = "*{email}"&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label&gt; Password &lt;/label&gt;
          &lt;input type = "text" th:field = "*{password}"/&gt;
      &lt;/div&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and it works.  I can enter data and hit the submit button and I'm in the doLogin method.  However, I would like to keep this mapping of GET and POST to the same url to do different things based on the request method.</p>
  
  <p>Further more, when I created the form at first, I forgot to specify a method="post" and while testing it submitted get requests to "/login" from this form.  Perhaps that wired something up that needs to be unwired.</p>
  
  <p>Is this a bug?  I can map the same url with different request methods to other controller methods but this one doesn't seem to want to work.  Any Ideas?</p>