title: GetMapping and PostMapping annotations
body: <p>I have  a doubr about this operation. Creating this class controller works:</p>
  
  <pre><code>@Controller
  public class StudentController {
  @RequestMapping(value = "/student", method = RequestMethod.GET)
  public ModelAndView student() {
  return new ModelAndView("student", "command", new Student());
  }
  
  @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
  public String addStudent(@ModelAttribute("SpringWeb")Student student,
  ModelMap model) {
  model.addAttribute("name", student.getName());
  model.addAttribute("age", student.getAge());
  model.addAttribute("id", student.getId());
  return "result";
  }
  </code></pre>
  
  <p>But using GetMapping and PostMapping does not work, the project runs normally, but does not display the page call. Ie. :</p>
  
  <pre><code>@Controller
      public class StudentController {
  
      @GetMapping("/student")
      public ModelAndView student() {
      return new ModelAndView("student", "command", new Student());
      }
  
      @PostMapping("/addStudent")
      public String addStudent(@ModelAttribute("SpringWeb")Student student,
      ModelMap model) {
      model.addAttribute("name", student.getName());
      model.addAttribute("age", student.getAge());
      model.addAttribute("id", student.getId());
      return "result";
      }
  }
  </code></pre>
  
  <p>Code full, the way below works correctly :</p>
  
  <p>Student.java </p>
  
  <pre><code>public class Student {
  
      private Integer age;
      private String name;
      private Integer id;
  
      public Integer getAge() {
          return age;
      }
      public void setAge(Integer age) {
          this.age = age;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }   
  }
  </code></pre>
  
  <p>StudentController</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  public class StudentController {
  
      @RequestMapping(value = "/student", method = RequestMethod.GET)
      public ModelAndView student() {
          return new ModelAndView("student", "command", new Student());
      }
  
      @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
      public String addStudent(@ModelAttribute("SpringWeb") Student student, ModelMap model) {
          model.addAttribute("name", student.getName());
          model.addAttribute("age", student.getAge());
          model.addAttribute("id", student.getId());
          return "result";
      }
  }
  </code></pre>
  
  <p>result.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
    &lt;head&gt;
   &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
   &lt;title&gt;Spring MVC Form Handling&lt;/title&gt;
   &lt;/head&gt;
    &lt;body&gt; 
       &lt;h2&gt;Submitted Student Information&lt;/h2&gt;
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td&gt;Name&lt;/td&gt;
                &lt;td&gt;${name}&lt;/td&gt;
            &lt;/tr&gt;          
              &lt;tr&gt;
                &lt;td&gt;Age&lt;/td&gt;
                  &lt;td&gt;${age}&lt;/td&gt;
                &lt;/tr&gt;     
                   &lt;tr&gt;
                     &lt;td&gt;ID&lt;/td&gt;
                      &lt;td&gt;${id}&lt;/td&gt;
                       &lt;/tr&gt;
                      &lt;/table&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>student.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;    
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Spring MVC Form Handling&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;h2&gt;Student Information&lt;/h2&gt;
      &lt;form:form method="POST" action="/HelloForm/addStudent"&gt;
  
      &lt;table&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;form:label path="name"&gt;Name&lt;/form:label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;form:input path="name" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;&lt;form:label path="age"&gt;Age&lt;/form:label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;form:input path="age"/&gt;&lt;/td&gt;
       &lt;/tr&gt;                  
      &lt;tr&gt;
    &lt;td&gt;&lt;form:label path="id"&gt;ID&lt;/form:label&gt;&lt;/td&gt;
    &lt;td&gt;&lt;form:input path="id"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td colspan="2"&gt;
    &lt;input type="submit" value="Submit" /&gt;
   &lt;/td&gt;
     &lt;/tr&gt;
          &lt;/table&gt;            
      &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>SpringContext.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"&gt;
  
  &lt;context:component-scan base-package="com" /&gt;
  
  &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
  &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
  &lt;property name="suffix" value=".jsp"/&gt;
  
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;HelloForm&lt;/display-name&gt;
  
    &lt;servlet&gt;
       &lt;servlet-name&gt;HelloForm&lt;/servlet-name&gt;
       &lt;servlet-class&gt;
  org.springframework.web.servlet.DispatcherServlet
  &lt;/servlet-class&gt;
       &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;HelloForm&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>