title: Passing object's variable to controller in thymeleaf
body: <p>I'm trying to create my very first CRUD ever.
  Here's my journeySite.html table code.</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr th:each="trip : ${trips}"&gt;
          &lt;td th:text="${trip.title}"&gt;&lt;/td&gt;
          &lt;td th:text="${trip.destination}"&gt;&lt;/td&gt;
          &lt;td th:text="${trip.id}"&gt;&lt;/td&gt;
              &lt;form th:action="@{/journeys}" th:object="${trip}" method="post"&gt;
                  &lt;input type="hidden" th:field="${trip.id}" /&gt;
                  &lt;button type="submit"&gt;Delete&lt;/button&gt;
              &lt;/form&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And make a my controller looks now like that.</p>
  
  <pre><code>@RequestMapping(value = {"/journeys"}, method = RequestMethod.GET)
  public String journeysPage(Model model){
      tripRepository.save(new Trip("Asian Trip", "Asia"));
      tripRepository.save(new Trip("European Trip", "Europe"));
      tripRepository.save(new Trip("African Trip", "Africa"));
  
      model.addAttribute("trips", tripRepository.findAll());
      return "journeysSite";
  }
  
  @RequestMapping(value = {"/journeys"}, method = RequestMethod.POST)
  public String journeysPageTripDeleting(@RequestParam Long id) {
      tripRepository.delete(id);
      return "journeysSite";
  }
  </code></pre>
  
  <p><strong>All i want is to show my all my trips on the /journeys in table. In each row there'd be a delete button which would POST trip.id, delete it from db and redirect to the exact same page, but with trip deleted.</strong></p>
  
  <p>But obviously error has occured: <code>java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'id' available as request attribute
      at org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:144) ~[spring-webmvc-4.3.6.RELEASE.jar:4.3.6.RELEASE]</code></p>
  
  <p>Would anyone give me a tip how to do it? Thanks.</p>