title: How to send thymeleaf value to spring controller
body: <p>I am new with Spring and Thymeleaf. I am building a simple app to rate films and series. I have a html table with some information about serie including current rating. To display a current rate I need to send a serie id to my spring controller, but don't know how to do that. I was trying with <code>th:with=&quot;serie_Id=${tempSerie.id}&quot;</code> but it doesn't work as I wish. The theId variable is always null.
  Here is my controller:</p>
  <pre><code>  @GetMapping(&quot;/list&quot;)
  public String listSeries(@Param(&quot;serie_Id&quot;) Integer theId, Model theModel, @Param(&quot;keyword&quot;) String keyword){
  
  
      String username;
  
  
      Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      if(principal instanceof UserDetails){
          username = ((UserDetails)principal).getUsername();
      }
      else {
          username = principal.toString();
      }
      System.out.println(theId);
      User theUser = userService.findByUsername(username);
      Serie theSerie = serieService.findById(theId);
  
      int theRating;
  
      try{
          theRating = serieRatingService.findByUserAndSerie(theUser, theSerie).getSerieRating();
      }
      catch (NullPointerException e){
          theRating = 0;
      }
  
      List&lt;Serie&gt; theSeries = serieService.findAll(keyword);
      theModel.addAttribute(&quot;serie_Id&quot;, theId);
      theModel.addAttribute(&quot;series&quot;, theSeries);
      theModel.addAttribute(&quot;ratings&quot;, theSeries);
      theModel.addAttribute(&quot;keyword&quot;, keyword);
      theModel.addAttribute(&quot;theRating&quot;, theRating);
  
      return &quot;series/list-series&quot;;
  }
  </code></pre>
  <p>Here is snippet of my view:</p>
  <pre><code> &lt;table class=&quot;table table-bordered table-striped&quot;&gt;
      &lt;thead class=&quot;thead-dark&quot;&gt;
      &lt;tr&gt;
          &lt;th&gt;Title&lt;/th&gt;
          &lt;th&gt;Release Year&lt;/th&gt;
          &lt;th&gt;Current Rate&lt;/th&gt;
          &lt;th&gt;Action&lt;/th&gt;
  
      &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
      &lt;tr th:each=&quot;tempSerie : ${series}&quot;&gt;
  
          &lt;td th:text=&quot;${tempSerie.title}&quot; /&gt;
          &lt;td th:text=&quot;${tempSerie.release_year}&quot; /&gt;
          &lt;td&gt;
  
              &lt;p&gt;&lt;svg width=&quot;1em&quot; height=&quot;1em&quot; viewBox=&quot;0 0 16 16&quot; class=&quot;bi bi-star-fill&quot; fill=&quot;currentColor&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
                  &lt;path d=&quot;M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.283.95l-3.523 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z&quot;/&gt;
              &lt;/svg&gt;&lt;span th:with=&quot;serie_Id=${tempSerie.id}&quot; th:text=&quot;${theRating}&quot;&gt;&lt;/span&gt;&lt;/p&gt;
  
  
          &lt;/td&gt;
          &lt;td&gt;
              &lt;div sec:authorize=&quot;hasRole('ROLE_ADMIN')&quot;&gt;
  
  
                  &lt;a th:href=&quot;@{/series/showFormForUpdate(serieId=${tempSerie.id})}&quot;
                     class=&quot;btn btn-info btn-sm&quot;&gt;
                      Update
                  &lt;/a&gt;
  
                  &lt;a th:href=&quot;@{/series/delete(serieId=${tempSerie.id})}&quot;
                     class=&quot;btn btn-danger btn-sm&quot;
                     onclick=&quot;if (!(confirm('Are you sure?'))) return false&quot;&gt;
                      Delete
                  &lt;/a&gt;
              &lt;/div&gt;
              &lt;div sec:authorize=&quot;hasRole('ROLE_USER')&quot;&gt;
  
                  &lt;a th:href=&quot;@{/serieRatings/showFormForSerieRate(serieId=${tempSerie.id})}&quot;
                     class=&quot;btn btn-warning&quot;&gt;
                      Rate
                  &lt;/a&gt;
  
              &lt;/div&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>
  <p>I want my table to be like this. The serie id is just hard-coded.
  <a href="https://i.stack.imgur.com/3w7yQ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/3w7yQ.png</a></p>