title: adding a custom login controller with spring security
body: <p>An app built from the <a href="https://github.com/spring-projects/spring-petclinic" rel="noreferrer">spring petclinic sample app</a> has added spring security with a custom login form.  </p>
  
  <p>The app does not have a WebMvcConfiguration.java class as suggested by <a href="http://docs.spring.io/spring-security/site/docs/3.2.x/guides/form.html" rel="noreferrer"> this tutorial</a>.  Instead, it has the following line in <code>mvc-core-config.xml</code>:  </p>
  
  <pre><code>&lt;mvc:view-controller path="/login" view-name="login" /&gt;
  </code></pre>
  
  <p>I have done <code>Ctrl-H</code> in eclipse and done a key word search for the term <code>/login</code> in the entire workspace, but no controller is visible.  I also looked in the <code>messages-jc</code> sample project referred to in the tutorial link above, but could not find a "<code>/login</code>" controller there either.</p>
  
  <p><strong>How can I add a controller that will perform spring authentication with the standard username and password, but that will also allow me to subsequently add additional code to the authentication process when the login form at the "/login" url is submitted?</strong></p>
  
  <p>Is it as simple as adding the following to <code>SomeOtherController.java</code> :  </p>
  
  <pre><code>@RequestMapping(value = "/login", method = RequestMethod.GET)
  public String showLoginForm(Model model) {
          //what goes here?       
      return "public/loginform";
  }
  
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public String processLoginForm(HttpSession session, @ModelAttribute("user") User user,
          BindingResult result, Model model, final RedirectAttributes redirectAttributes)
  {
          //what goes here?
      return "secure/main";
  }
  </code></pre>