title: How to pass form data via controller with Spring MVC 3.1 - new to Spring MVC
body: <p>I'm new to spring, as well as spring mvc. I'm using version 3.1. Also, for now, I'm using Tomcat 7 and MySQL 5.5. I have data in a database table which I can display on a web page. Now, I'm trying to add data to my database from a web form, and then display that data on a web page. </p>
  
  <p><strong>Here is part of my runtime error when I try to invoke my web form:</strong></p>
  
  <p>** Root cause is: Request method 'GET' not supported org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:665) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:431) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at </p>
  
  <p><strong>Here is the section of my controller in question</strong>. Note, if I just have the @RequestMapping("/newProfile") line, instead of the other @RequestMapping line, then I get a web page, without my data showing, which is what I would expect, since I haven't plugged in my DAO layer just yet.</p>
  
  <pre><code>    @RequestMapping(value = "/newProfile", method = {RequestMethod.POST})
  //@RequestMapping("/newProfile")
  public String addNewProfile(@ModelAttribute("profile")Profile profile, ModelMap model) {
        model.addAttribute("firstName", profile.getFirstName());
        model.addAttribute("lastName", profile.getLastName());
        return "newProfileResult";
     }
  </code></pre>
  
  <p><strong>Here is my input web form (using JSP for the moment):</strong></p>
  
  <pre><code>&lt;%@ include file="/WEB-INF/jsp/includes.jsp" %&gt;
  &lt;%@ include file="/WEB-INF/jsp/header.jsp" %&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Profile Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Information&lt;/h2&gt;
  &lt;form:form method="POST" action="/newProfile"&gt;
     &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="firstName"&gt;First Name&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="firstName" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="lastName"&gt;Last Name&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="lastName" /&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;
  </code></pre>
  
  <p></p>