title: maintain state with spring between requests
body: <p>I am new to spring so sorry if this is a beginners question, but the manual is not clear (at least not for me)</p>
  
  <p>My question is: how do I share state between requests in spring?
  I can send data from the controller to the view by using a ModelMap, but the data in the ModelMap is not sent back to the next controller by the view.
  How can I do this with spring?</p>
  
  <p>Below is a part of my source code. In the second controller the modelMap doesn't contain the data I stored in the modelMap in the first controller.
  How am I supposed to maintain state between controllers in spring?</p>
  
  <p>thanks a lot for help.</p>
  
  <pre><code>@RequestMapping(value = "find/something", method = RequestMethod.GET)
  public String foo(@RequestParam("parent") Parent parent, ModelMap modelMap) {    
  ...
      modelMap.addAttribute("question_index", 42);
      modelMap.addAttribute("something", new Something());
      modelMap.addAttribute("data", new Data());
      return "some/view";
  }
  
  &lt;form:form action="bla" method="POST"  modelAttribute="data"&gt;
  ...// using Something() and 42
  &lt;/form:form&gt;
  
  @RequestMapping(value = "bla", method = RequestMethod.POST)    
  public String bla(@ModelAttribute("data") Data data, BindingResult result, ModelMap modelMap) {
  System.out.println(modelMap); // doesn't contain question_index, or something
  }
  </code></pre>