title: Spring MVC + Thymeleaf: passing objects through pages
body: <p>I'm developing a simple web application using spring MVC and thymeleaf. I have a form correctly handled by this method in my controller</p>
  
  <pre><code>@RequestMapping(value = "/list", method = RequestMethod.POST)
  public ModelAndView searchJob(
          @ModelAttribute(SEARCH_PARAMS) @Valid SearchParams params,
          BindingResult bindingResult) {
      ModelAndView output = null;
  
      if (!bindingResult.hasErrors()) {
  
          JobsAPIImplService service = new JobsAPIImplService();
          JobsAPI api = service.getJobsAPIImplPort();
  
          ArrayList&lt;NoaJob&gt; jobs = (ArrayList&lt;NoaJob&gt;) (api.search(JobUtils.toSearchParams(params))).getItem();
  
          output = new ModelAndView("scheduler/list");
          output.addObject("jobs", jobs);
      } else { 
       // errors handling
      }
  
      return output;
  }
  </code></pre>
  
  <p>So in my result page I can access to the ArrayList "jobs" in this way:</p>
  
  <pre><code>&lt;tr th:each="job : ${jobs}"&gt;
      ...
  &lt;/tr&gt;
  </code></pre>
  
  <p>In the same page, I have a simple link which calls another GET method on the same controller. The goal here is to have the same ArrayList in another page in order to implement a "back" button without re-executing the search logic (a call to a web service). 
  Here is the method called</p>
  
  <pre><code>@RequestMapping(value="/list/{id}", method = RequestMethod.GET)
  public ModelAndView details(@PathVariable("id") String jobUuid,
          @ModelAttribute("jobs") ArrayList&lt;NoaJob&gt; jobs) {
      ModelAndView output = new ModelAndView("scheduler/details");
  
      LOGGER.info("Size jobs list: " + jobs.size());
  
      NoaJob job = new NoaJob();
      job.setJobUuid(jobUuid);
      output.addObject("job", job);
      output.addObject("jobs", jobs);
  
      return output;
  }
  </code></pre>
  
  <p>the problem is that the arraylist here is always null! I read that in GET requests Spring allocates a new ModelAttribute, so how can I pass this object throug pages?</p>