title: PostMapping Spring boot annotation is not working
body: <p>I am new to spring boot and do not know why my @PostMapping is not working and leading to a white label error. Everything else works fine and I can add customers to the h2 database. However, once I add customers and go to URL localhost:8084/getdetails and type 1, a white label error occurs. However, the form in the ViewCustomers.jsp file is still displayed but cannot take in any input. The form should invoke toString() of the customer object and its fields. </p>
  
  <p>Controller  </p>
  
  <pre><code>package com.example.demo;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  @Controller
  public class FormController {
    @Autowired
    CustomerRepo repo;
  
    @RequestMapping("/")
    public String details() {
      return "edureka";
    }
  
    @RequestMapping("/details")
    public String details(Customers customers) {
      repo.save(customers);
      return "edureka";
    }
  
    @RequestMapping("/getdetails")
    public String getdetails() {
      return "ViewCustomers";
    }
  
    @PostMapping("/getdetails")
    public ModelAndView getdetails(@RequestParam int cid) {
      System.out.println("here");
      ModelAndView mv = new ModelAndView("Retrieve");
      Customers customers = repo.findById(cid).orElse(null);
      mv.addObject(customers);
      return mv;
    }
  }
  </code></pre>
  
  <p>edureka.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Edureka Customers&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" action="details"&gt;
          Enter Customer ID: &lt;input type="text" name="cid"&gt;&lt;br&gt;&lt;br&gt;
          Enter Customer Name: &lt;input type="text" name="cname"&gt;&lt;br&gt;&lt;br&gt;    
          Enter Customer Email Address: &lt;input type="email" name="cemail"&gt;&lt;br&gt;&lt;br&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>ViewCustomer.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;View Customer Details&lt;/h1&gt;
      &lt;h2&gt;Details as submitted as follows&lt;/h2&gt;
      &lt;form method="getdetails" action="post"&gt;
          &lt;input type="number" name="cid"&gt;&lt;br&gt; 
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Retrieve.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Retrieve Customer Details&lt;/h1&gt;
      &lt;h2&gt;Details as submitted as follows:&lt;/h2&gt;
      &lt;h5&gt;${customers}&lt;/h5&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Customers.java</p>
  
  <pre><code>package com.example.demo;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity
  public class Customers {
    @Id
    private int cid;
    private String cname;
    private String cemail;
  
    public int getCid() {
      return cid;
    }
  
    public void setCid(int cid) {
      this.cid = cid;
    }
  
    public String getCname() {
      return cname;
    }
  
    public void setCname(String cname) {
      this.cname = cname;
    }
  
    public String getCemail() {
      return cemail;
    }
  
    public void setCemail(String cemail) {
      this.cemail = cemail;
    }
  
    @Override
    public String toString() {
      return "Customers [cid=" + cid + ", cname=" + cname + ", cemail=" + cemail + "]";
    }
  }
  </code></pre>
  
  <p>CustomerRepo interface
      package com.example.demo;</p>
  
  <pre><code>import org.springframework.data.repository.CrudRepository;
  
  public interface CustomerRepo extends CrudRepository&lt;Customers,Integer&gt;{
  
  }
  </code></pre>
  
  <p>SubmissionFormApplication.java</p>
  
  <pre><code>package com.example.demo;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.builder.SpringApplicationBuilder;
  import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  import org.springframework.context.annotation.ComponentScan;
  import com.example.demo.SubmissionFormApplication;
  
  @ComponentScan
  @SpringBootApplication
  public class SubmissionFormApplication extends SpringBootServletInitializer{
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SubmissionFormApplication.class);
      }
      public static void main(String[] args) {
          SpringApplication.run(SubmissionFormApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.1.13.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;SubmissionForm&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;SubmissionForm&lt;/name&gt;
      &lt;description&gt;First Spring Boot Web app&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jersey&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;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web-services&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&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;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
              &lt;version&gt;9.0.31&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>