title: How to pass data between requests of Post/Redirect/Get pattern in Spring MVC?
body: <p>I have a form which submits user first and last name using POST signin.html</p>
  
  <pre><code> @RequestMapping(value="/signin.html",method = RequestMethod.POST)
   public ModelAndView submit(@Valid User user){
      ModelAndView mv = new ModelAndView("redirect:signin.html"); 
      //Business logic with user account
      return mv;
   } 
  </code></pre>
  
  <p>In order to solve double submit problem I'm redirecting to the same mapping using GET request. </p>
  
  <pre><code> @RequestMapping(value="/signin.html",method = RequestMethod.GET)
   public ModelAndView submitPRG(){
       ModelAndView mv = new ModelAndView("submitted");
       mv.addObject("message", "Submitted Correctly");
       return mv;
   }
  </code></pre>
  
  <p>This way I solve double submit problem. </p>
  
  <p>I have few questions:</p>
  
  <p>1) How can I know that GET request on /signin.html coming from redirect and was not requested by user in browser? I just would like to close option for user to browse <a href="http://server/signin.html" rel="nofollow">http://server/signin.html</a> and to get "Submitted Correctly" message.   I know that I can add something like /signin.html?submitted=true but I would like to make it more clean.</p>
  
  <p>2) is there any way to pass <code>ModelAndView</code> object from <code>submit()</code> to <code>submitPRG()</code>?</p>
  
  <p>Or simply is there any other way to use PRG in this case?   </p>