title: Spring MVC and Ajax: error 404 when calling URL that uses a Token
body: <p>I'm implementing a "forgot password" feature. I'm using Spring MVC and Ajax but I'm having some trouble when I want to call the spring controller method through Ajax, using a token url. The code I have is something like this:</p>
  
  <p><strong>Spring Controller</strong> </p>
  
  <pre><code>@RequestMapping(value="/resetPassword/{token}", method = RequestMethod.POST)
  public @ResponseBody String doResetPassword(@PathVariable("token") String tokenID, 
          @RequestParam String newPassword, HttpServletRequest request) { ... }
  </code></pre>
  
  <p>The <em>token</em> is the unique id that randomly generates when the user requests a password reset and gets a temporary link via email that redirects him/her to the Reset Password page.</p>
  
  <p><strong>Ajax function</strong></p>
  
  <pre><code>         $.ajax({
                type: "POST",
                url: "./resetPassword/" + token,
                data: "newPassword=" + password,    
                async: false,
                success: function(response){               
                   ...  
  </code></pre>
  
  <p>When I make the Ajax call, I get a <strong>404 Page Not Found</strong> error.</p>
  
  <p><strong>NOTE:</strong> The URL format works. I already have other Ajax functions using the <code>./</code><br>
  The controller method that shows the Reset Password form is as follows:</p>
  
  <pre><code>@RequestMapping(value="/resetPassword/{token}")
  public String showResetPasswordPage(Model model, @PathVariable("token") String token){
      model.addAttribute("token", token);
      return "account/resetPassword";
  }
  </code></pre>
  
  <p>The issue appears with the previous request method, when the user actually clicks the button (after entering new password).</p>