title: Spring Boot - Request method 'POST' not supported (Method not allowed)
body: <p>As I followed this tutorial: <a href="https://spring.io/guides/gs/handling-form-submission/" rel="nofollow noreferrer">https://spring.io/guides/gs/handling-form-submission/</a> after a while I came to a dead end. I tried to figure out what the problem is for some hours now. I hope you can help me.</p>
  
  <p>When I submit my form, I get this error-message:</p>
  
  <pre><code> There was an unexpected error (type=Method Not Allowed, status=405).
   Request method 'POST' not supported
  </code></pre>
  
  <p>My App (App.java):</p>
  
  <pre><code>package de.poc.logging.main;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  @SpringBootApplication
  public class App {
    public static void main(String[] args) {
      SpringApplication.run(App.class, args);
    }
  }
  </code></pre>
  
  <p>My Controller (InformationController.java):</p>
  
  <pre><code>package de.poc.logging.main;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  @RequestMapping(value = "/info")
  public class InformationController {
    @RequestMapping(method = RequestMethod.GET, produces = "text/html")
    public String infoForm(Model model) {
      model.addAttribute("information", new Information());
      return "infoForm.html";
    }
  
    @RequestMapping(method = RequestMethod.POST, produces = "text/html")
    public String infoSubmit(@ModelAttribute Information information) {
      return "infoResult.html";
    }
  }
  </code></pre>
  
  <p>I created an additional class for security (WebSecurityConf.java):</p>
  
  <pre><code>package de.poc.logging.main.config;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  
  @Configuration
  @EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
      http.headers()
          .frameOptions().sameOrigin()
          .httpStrictTransportSecurity().disable();
      http.csrf().disable();
    }
  }
  </code></pre>
  
  <p>And I have following two HTML-Files:</p>
  
  <p>infoForm.html:</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
      &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
      &lt;head&gt;
          &lt;title&gt;Getting Started: Handling Form Submission&lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;h1&gt;Form&lt;/h1&gt;
      &lt;form action="#" th:action="@{/info}" th:object="${information}" method="post"&gt;
          &lt;p&gt;Id: &lt;input type="text" th:field="*{id}"/&gt;&lt;/p&gt;
          &lt;p&gt;Message: &lt;input type="text" th:field="*{content}"/&gt;&lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Submit"/&gt;
              &lt;input type="reset" value="Reset"/&gt;&lt;/p&gt;
          &lt;!--&lt;input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/&gt;--&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>infoResult.html:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;title&gt;Getting Started: Handling Form Submission&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Result&lt;/h1&gt;
  &lt;p th:text="'id: ' + ${information.id}"/&gt;
  &lt;p th:text="'content: ' + ${information.content}"/&gt;
  &lt;a href="/info"&gt;Submit another message&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Edit (additional information):
  my Information.java:</p>
  
  <pre><code>package de.poc.logging.main;
  
  public class Information {
    private long id;
    private String content;
  
    public long getId() {
      return id;
    }
  
    public String getContent() {
      return content;
    }
  
    public void setId(long id) {
      this.id = id;
    }
  
    public void setContent(String content) {
      this.content = content;
    }
  
  }
  </code></pre>
  
  <p>my pom-dependencies:</p>
  
  <pre><code>    &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
              &lt;version&gt;1.5.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;version&gt;1.5.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
              &lt;version&gt;1.5.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  
  <p>I'm using Java 1.8u121 (jdk).</p>
  
  <p>Edit2:
  I tried 3 different versions of spring boot now.
  Also I downloaded the project from here: <a href="https://github.com/spring-guides/gs-handling-form-submission" rel="nofollow noreferrer">https://github.com/spring-guides/gs-handling-form-submission</a> and added spring boot via pom.xml.
  The downloaded project does not work for me.</p>
  
  <p>I'm getting really frustrated.</p>