title: How to send variable to controller not as form input in Spring Boot
body: <p>I am using Spring Boot with Tymeleaf and am fairly new to it. I am using the Twitter API to make an app. I have a list of tweets displayed using <code>th:each</code>. When the user clicks the retweet button for a tweet, that particular tweet's id should be sent to the controller as a parameter for the retweet method, so that it can be processed there. The user should not be aware of the id from the front-end.</p>
  
  <p>As of now my only solution is to include the id as a url in an 'a' tag and have it be taken as a path variable using <code>@PathVariable</code> in the controller and return the index page which has the list of tweets. This works fine but I do not like this method as the user should not have to leave the page and I may later prefer use a modal. Basically I want to know of a way to send the id to the controller without having it displayed in HTML.</p>
  
  <p>index.html</p>
  
  <pre><code> &lt;div class="result" th:each="result : ${results}"&gt;
              &lt;h3&gt;&lt;a th:href="${result.fromUser}" th:text="${result.user.name}"&gt;&lt;/a&gt;&lt;/h3&gt;
  
              &lt;p th:text="'@' + ${result.fromUser}"&gt;&lt;/p&gt;
              &lt;span th:text="${result.text}"&gt;&lt;/span&gt;
              &lt;div id="retweet"&gt;
                      &lt;a th:href="'user/' +  ${result.id}"&gt;Retwt&lt;/a&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Maincontroller.java</p>
  
  <pre><code>@RequestMapping(value = "")
  public String getUserProfile(Model model) {
      TwitterProfile userInfo = twitterService.getUserProfile();
      List&lt;Tweet&gt; homeTimeline = twitterService.getUserTimeline();
      model.addAttribute("profileImg", userInfo.getProfileImageUrl());
      model.addAttribute("results", homeTimeline);
      return "pages/index";
  }
  
  @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
  public String retweet(@PathVariable long id) {
      twitterService.retweet(id);
      return "/";
  }
  </code></pre>