title: Trying to get two path variables into spring mvc controller
body: <p>I am trying to get multiple path variables into a spring mvc controller but I am getting the following error </p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>          SEVERE: Servlet.service() for servlet [stp] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: public java.lang.String edu.bnu.fyp.stp.web.controller.WatchlistController.saveWatchlist java.lang.String,java.lang.String,org.springframework.validation.BindingResult,org.springframework.web.bind.annotation.ModelAttribute,javax.servlet.http.HttpSession)] with root cause java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: public java.lang.String edu.bnu.fyp.stp.web.controller.WatchlistController.saveWatchlit(java.lang.String,java.lang.String,org.springframework.validation.BindingResult,org.springframework.web.bind.annotation.ModelAttribute,javax.servlet.http.HttpSession)
  </code></pre>
  
  <p>Here is what I am trying to do</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>@RequestMapping(value = "/add/{tutorId}/{studentId}" , method = RequestMethod.GET)
  public String saveWatchlist(@PathVariable(value = "tutorId") String tutorId, @PathVariable(value = "studentId") String studentId , BindingResult bindingResult, ModelAttribute model, HttpSession session) {
  
      System.out.println("Tutor ID is: " + tutorId);
      System.out.println("Student ID is: " + studentId);
  
      return "StudentWatchlist";
  }
  </code></pre>
  
  <p><strong>JSP:</strong></p>
  
  <pre><code> &lt;a href="${pageContext.request.contextPath}/watchlist/add/${tutorList.userId}/${sessionScope.user.userId}"&gt; Add &lt;/a&gt;
  </code></pre>
  
  <p><strong>Note:</strong></p>
  
  <p>This URL is working and in JSP you can actually see the URL calling the controller with both IDs in the link. But for some reason, I am not able to catch these values in the controller. I have also tried the RequestParm solution, it didn't work either.</p>