title: How to put an attribute in the URL
body: <p>I have gone through url mapping topics but I couldn't find a way to solve my problem despite I'm sure more than one has had this kind of setback. Maybe it is quite simple.</p>
  
  <p>I have a login process, when the login form is submited (user and password) 
  localhost:8080/library/login the controller leads to the main page of the user, All I would like to do is to set the username in the URL like localhost:8080/library/{username}/mainPage
  It seems it has nothing to do with PathVariable or RequestParam as I tried many ways to go through this however 400 error is all I got.</p>
  
  <pre><code>@RequestMapping(value="/mainPage", method = RequestMethod.POST)
  public ModelAndView showMainPage(@Valid @ModelAttribute("loginUserForm") LoginUserForm loginUserForm, ModelAndView modelAndView, BindingResult result, final RedirectAttributes attributes){
      logger.info("Showing login page.");
      modelAndView.addObject(loginUserForm);
      attributes.addFlashAttribute("loginUserForm", loginUserForm);
      if(result.hasErrors()){
          modelAndView.setViewName("login");
          return modelAndView;
      }
  
      modelAndView.setViewName("mainPage");
      return new ModelAndView("redirect:/mainPage");
  }
  </code></pre>
  
  <p>And this leads to another controller class</p>
  
  <pre><code>@RequestMapping(value = "/{userName}/mainPage", method = RequestMethod.GET)
  public @ResponseBody ModelAndView showMyArea(ModelAndView model, @ModelAttribute("loginUserForm") LoginUserForm loginUserForm, @PathVariable("email")String email){
      logger.debug("Showing mainPage");
      ModelAndView modelAndView = new ModelAndView();
      modelAndView.setViewName("mainPage");
      return modelAndView;
  }
  </code></pre>
  
  <p>What should I change or what do I miss? I guess the value, but I do not why</p>
  
  <p>I came up with this wrongly:</p>
  
  <pre><code>@RequestMapping(value="/{userName}/mainPage", method = RequestMethod.POST)
  public ModelAndView showMainPage(@Valid @ModelAttribute("loginUserForm") LoginUserForm loginUserForm, ModelAndView modelAndView, BindingResult result, @PathVariable("userName") String userName){
  </code></pre>
  
  <p>Thanks a ton!</p>