title: Submit on create user page doesn't go to createuser method in spring-mvc controller
body: <p>I normally work on JAX-RS REST services, and I have to make some changes to a webapp using Spring MVC, which I'm only superficially familiar with (the MVC part, not Spring).</p>
  
  <p>I have a view that lets the user create new users.  When the form is submitted, instead of hitting the appropriate action in the Spring MVC controller, the page just "blanks out", as if it forwarded to a view that doesn't exist.</p>
  
  <p>It's not clear to me what to look for here.  Perhaps there's some logging I can enable that will show what request mapping decision Spring makes?</p>
  
  <p>I'll try to show the relevant pieces of code here.</p>
  
  <p>Inside the jsp page that has the form for the user/password/name fields, there's something like this:</p>
  
  <pre><code>&lt;a href="#" onclick="validateUserCredentials();return false;" class="button"&gt;Create User&lt;/a&gt;
  </code></pre>
  
  <p>I set a breakpoint in "validateUserCredentials()", which does some trivial validation of the entry fields:</p>
  
  <pre><code>function validateUserCredentials(){
      var inputPassword=/[a-zA-Z0-9_-]{4,14}/ ;
      var inputUsername=/[a-zA-Z0-9_-]{4,14}/ ;
      var error ="false";
      if (document.f.password.value.search(inputPassword)==-1)
      {
          error="true";
      }else if (document.f.username.value.search(inputUsername)==-1){
          error="true";       
      }else if (document.f.fullname.value.length==0){
          error="true";
      }else if (document.f.displayName.value.length==0){
          error="true";
      }
      if(error =="true"){
          document.f.action="/account/createuser?error=true";
          document.f.submit();        
      }else{
      document.f.action="/account/createuser";
      document.f.submit();
      }
  }
  </code></pre>
  
  <p>Here is an excerpt of the controller:</p>
  
  <pre><code>@Controller
  @SessionAttributes(value= {"userRoleMap", "userStatusMap"})
  public class AccountController {
  
      private static Logger   logger  = LogManager.getLogger(AccountController.class);
  
      @Autowired
      private UserAccountService accountService;
  
      @RequestMapping(value = "/account/getCurrentUsers", method = RequestMethod.GET)
      public ModelAndView getCurrentUsers(ModelMap model) {
          logger.debug("In getCurrentUsers.");
          List&lt;UserInfo&gt; userInfoList =accountService.getCurrentUserList();
          Users users = new Users();
          users.setUserInfoList(userInfoList);
          HashMap&lt;String,String&gt; userRoleMap=populateAndGetUseridRoleMap(userInfoList);
          HashMap&lt;String,Boolean&gt; userStatusMap=populateAndGetUseridStatusMap(userInfoList);
          model.addAttribute("userRoleMap",userRoleMap);
          model.addAttribute("userStatusMap",userStatusMap);
          return new ModelAndView("userRole","users",users);
      }
  
      @RequestMapping(value = "/account/createuser", method = RequestMethod.GET)
      public String getCreateUserPage() {
          logger.debug("In getCreateUserPage.");
          return "createUser";
      }
  
      @RequestMapping(value = "/account/createuser", method = RequestMethod.POST)
      public String createUser(@RequestParam("username") String newUser,@RequestParam("password") String password,
              @RequestParam("role") String role,
              @RequestParam("fullname") String fullname, 
              @RequestParam("displayName") String displayName,
              @RequestParam(value="error", required=false) boolean error,ModelMap model) {
          logger.debug("In createUser. newUser[" + newUser + "] password[" + password + "] role[" + role +
                       "] fullname[" + fullname + "] displayname[" + displayName + "] error[" + error +
                       "] model[" + model + "]");
  </code></pre>
  
  <p>When I click the submit button, the page just "blanks out".  The url was at "/account/createuser" before the submit, and it didn't change after the submit.</p>
  
  <p>When I looked at the log, I only saw this:</p>
  
  <pre><code>controllers.AccountController (AccountController.java:73) - In getCurrentUsers.
  controllers.AccountController (AccountController.java:104) - In getCreateUserPage.
  </code></pre>
  
  <p>It didn't appear to get into the "createUser" method.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I also noticed earlier in the log the following line:</p>
  
  <pre><code>   org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/account/createuser],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String ...AccountController.createUser(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean,org.springframework.ui.ModelMap)
  </code></pre>