title: Spring MVC controller won't respond to POST from a form
body: <p>In short, I have a Spring 3.1 MVC project and my controller doesn't respond to the POST request when I hit the submit button.</p>
  
  <p>There is no error, just no response.  The controller method is not being called.  I have a logger in the method that displays an INFO message and nothing is displayed (other INFO messages do display).  MVC is working (at least partial) because I get a response from a "home" JSP page, but nothing for a POST.</p>
  
  <p>I'm including things that seem important; tell me if there's something you'd like to see.</p>
  
  <p>Controller class:</p>
  
  <pre><code>@Controller
  @RequestMapping("/register")
  public class EditorController {
  ...
  
      @RequestMapping(method = RequestMethod.POST)
      public String addEditorFromForm(@Valid Editor editor,
              BindingResult bindingResult) throws ClassNotFoundException,
              IOException {
  
          if (LOG.isInfoEnabled()) {
              LOG.info("In addEditorFromForm()");
          }
  
          // Form did not validate
          if (bindingResult.hasErrors()) {
              return "register/first_time";
          }
  
          getEditorDao().saveEditor(editor);
  
          // New editor still needs to login
          return "home";
      }
  
  }
  </code></pre>
  
  <p>WEB-INF/views/register/first_time.jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="sf" uri="http://www.springframework.org/tags/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=ISO-8859-1"&gt;
  &lt;link rel="stylesheet" type="text/css" href="&lt;c:url value='/resources/css/base.css' /&gt;"&gt;
  &lt;title&gt;Register for DIY Doctrine&lt;/title&gt;
  &lt;/head&gt;
  &lt;body class="center"&gt;
  
  &lt;h2&gt;Sign up for DIY Doctrine&lt;/h2&gt;
  
  &lt;sf:form method="POST" modelAttribute="editor"&gt;
  &lt;fieldset&gt;
      &lt;table cellspacing="0"&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;label for="username"&gt;Username:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;sf:input path="username" size="30" id="username"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;th&gt;&lt;label for="user_password"&gt;Password:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;sf:password path="password" size="30" showPassword="false"
                  id="user_password"/&gt;
          &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/fieldset&gt;
  &lt;input type="submit" value="Submit Registration" /&gt;
  &lt;/sf:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>You get the <code>register/first_time.jsp</code> from this method in the controller:</p>
  
  <pre><code>@RequestMapping(value = "first_time")
      public String displayForm(Model model) {
          if (LOG.isInfoEnabled()) {
              LOG.info("In displayForm()");
          }
          model.addAttribute(new Editor());
          return "register/first_time";
      }
  </code></pre>
  
  <p>These are the headers returned when you press the submit button in <code>register/first_time</code>:</p>
  
  <pre><code>Request URL:http://localhost:8080/doctrine/register/first_time
  Request Method:POST
  Status Code:200 OK
  Request Headersview source
  Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8,sl;q=0.6
  Cache-Control:max-age=0
  Connection:keep-alive
  Content-Length:34
  Content-Type:application/x-www-form-urlencoded
  Cookie:JSESSIONID=08209E778F63429CFA031A1DB53491DD
  Host:localhost:8080
  Origin:http://localhost:8080
  Referer:http://localhost:8080/doctrine/register/first_time
  User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.41 Safari/537.36
  Form Dataview sourceview URL encoded
  username:ngeorgewitz
  password:1234
  Response Headersview source
  Content-Language:en-US
  Content-Length:950
  Content-Type:text/html;charset=ISO-8859-1
  Date:Tue, 24 Dec 2013 20:28:19 GMT
  Server:Apache-Coyote/1.1
  </code></pre>