title: java.lang.IllegalArgumentException: id to load is required for loading
body: <p>This is my updateUser controller method</p>
  
  <pre><code> @RequestMapping(value = {"/edit-user-{id}"}, method = RequestMethod.POST)
          public String updateUser(@Valid User userForm, BindingResult bindingResult, ModelMap model, @PathVariable Long id) {
              model.addAttribute("edit", true);
              model.addAttribute("success", "User " + userForm.getFirstName() + " " + userForm.getLastName() + " updated successfully");
              userValidator.validate(userForm, bindingResult);
              if (bindingResult.hasErrors()) {
                  return "forward:/registration";
              }
              userService.updateUser(userForm);
              model.addAttribute("userForm", userForm);
  
              return "registrationSuccess";
      }
  </code></pre>
  
  <p>this one is my addDocuments method</p>
  
  <pre><code>@RequestMapping(value = {"/add-document-{id}"}, method = RequestMethod.GET)
      public String addDocuments(@PathVariable Long id, ModelMap model) {
          User user = userService.findById(id);
          try {
              if (user.getUsername() != null &amp;&amp; !user.getUsername().equals(context.getUserPrincipal().getName())) {
                  return "login";
              }
          } catch (Exception ex) {
              throw new DocumentNotFoundException("No document found with that id or userName");
          }
          model.addAttribute("user", user);
  
          FileBucket fileModel = new FileBucket();
          model.addAttribute("fileBucket", fileModel);
  
          List&lt;Catalog&gt; documents = catalogService.findAllByUserId(id);
          model.addAttribute("documents", documents);
  
          return "manageDocuments";
  }
  </code></pre>
  
  <p>when there is binding result error in updateUser method, it enters the "registration.jsp"</p>
  
  <p>and at that time when I press add document button, it throws this kind of exception</p>
  
  <pre><code>nested exception is java.lang.IllegalArgumentException: id to load is required for loading.
  </code></pre>
  
  <p>this is registration jsp</p>
  
  <pre><code>&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  
  &lt;c:set var="contextPath" value="${pageContext.request.contextPath}"/&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;meta name="comment" content=""&gt;
      &lt;meta name="author" content=""&gt;
  
      &lt;title&gt;Create an account&lt;/title&gt;
  
      &lt;link href="${contextPath}/resources/css/bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link href="${contextPath}/resources/css/common.css" rel="stylesheet"&gt;
  
      &lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div class="container"&gt;
      &lt;form id="logoutForm" method="POST" action="${contextPath}/logout"&gt;
          &lt;input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/&gt;
      &lt;/form&gt;
  
      &lt;form:form method="POST" modelAttribute="userForm" class="form-signin"&gt;
          &lt;c:choose&gt;
              &lt;c:when test="${edit}"&gt;
                  &lt;h2 class="form-signin-heading"&gt;&lt;spring:message code= "account.edit.label"/&gt;&lt;/h2&gt;
              &lt;/c:when&gt;
  
              &lt;c:otherwise&gt;
                  &lt;h2 class="form-signin-heading"&gt;&lt;spring:message code= "account.create.label"/&gt;&lt;/h2&gt;
              &lt;/c:otherwise&gt;
          &lt;/c:choose&gt;
  
          &lt;c:if test="${!edit}"&gt;
              &lt;spring:bind path="username"&gt;
                  &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                      &lt;form:input type="text" path="username" class="form-control" placeholder="Username"
                                  autofocus="true"&gt;&lt;/form:input&gt;
                      &lt;form:errors path="username"&gt;&lt;/form:errors&gt;
                  &lt;/div&gt;
              &lt;/spring:bind&gt;
          &lt;/c:if&gt;
          &lt;spring:bind path="firstName"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="text" path="firstName" class="form-control" placeholder="First name"
                              autofocus="true"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="firstName"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;spring:bind path="lastName"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="text" path="lastName" class="form-control" placeholder="Last name"
                              autofocus="true"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="lastName"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;spring:bind path="email"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="text" path="email" class="form-control" placeholder="Email"
                              autofocus="true"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="email"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;spring:bind path="skypeID"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="text" path="skypeID" class="form-control" placeholder="Skype ID"
                              autofocus="true"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="skypeID"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;spring:bind path="password"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="password" path="password" class="form-control" placeholder="Password"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="password"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;spring:bind path="passwordConfirm"&gt;
              &lt;div class="form-group ${status.error ? 'has-error' : ''}"&gt;
                  &lt;form:input type="password" path="passwordConfirm" class="form-control"
                              placeholder="Confirm your password"&gt;&lt;/form:input&gt;
                  &lt;form:errors path="passwordConfirm"&gt;&lt;/form:errors&gt;
              &lt;/div&gt;
          &lt;/spring:bind&gt;
  
          &lt;c:if test="${edit}"&gt;
              &lt;span class="well pull-left"&gt;
                  &lt;a href="&lt;c:url value='/add-document-${userForm.id}' /&gt;" class="btn btn-primary btn-sm"&gt;&lt;spring:message code= "button.upload.text"/&gt;&lt;/a&gt;
              &lt;/span&gt;
          &lt;/c:if&gt;
  
          &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;&lt;spring:message code= "button.submit.label"/&gt;&lt;/button&gt;
          &lt;h3&gt;&lt;a onclick="document.forms['logoutForm'].submit()"&gt;&lt;spring:message code= "button.logout.label"/&gt;&lt;/a&gt;&lt;/h3&gt;
      &lt;/form:form&gt;
  
  &lt;/div&gt;
  
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="${contextPath}/resources/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>please help me find out how to redirect or forward.</p>