title: Can I make HTTP POST request from Thymeleaf table in Spring Boot application
body: <p>I have a Thymeleaf template in a simple Spring Boot application. The template contains a list in a table as follows:</p>
  
  <pre><code>&lt;p&gt;There are &lt;span th:text="${#lists.size(persons)}"&gt;&lt;/span&gt; people:&lt;/p&gt;
  &lt;table th:if="${not #lists.isEmpty(persons)}" border="1"&gt;
      &lt;tr&gt;
          &lt;th&gt;ID&lt;/th&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Address&lt;/th&gt;
          &lt;th&gt;Telephone&lt;/th&gt;
          &lt;th&gt;Email&lt;/th&gt;
          &lt;th&gt;Actions&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr th:each="person : ${persons}"&gt;
          &lt;td th:text="${person.personId}"&gt;&lt;/td&gt;
          &lt;td th:text="${person.name}"&gt;&lt;/td&gt;
          &lt;td th:text="${person.address}"&gt;&lt;/td&gt;
          &lt;td th:text="${person.telephone}"&gt;&lt;/td&gt;
          &lt;td th:text="${person.email}"&gt;&lt;/td&gt;
          &lt;td&gt;
              &lt;a href="#" data-th-href="@{/edit(personId=${person.personId})}"&gt;Edit&lt;/a&gt; |
              &lt;a href="#" data-th-href="@{/delete(personId=${person.personId})}"&gt;Delete&lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I want to enable edit and delete functionality as per the last cell in the table. But at the moment both requests are for HTTP GET. That is fine for edit where a person's details are fetched from the server for editing, but delete should trigger a POST request because of the data changes on the server.</p>
  
  <p>Does anyone know if Thymeleaf allow a POST request per row of a table? Or do I have to write a simple HTML form per row?</p>
  
  <p>The GET form is currently:</p>
  
  <pre><code>&lt;td&gt;
      &lt;a href="#" data-th-href="@{/edit(personId=${person.personId})}"&gt;Edit&lt;/a&gt;
      &lt;!--a href="#" data-th-href="@{/delete(personId=${person.personId})}"&gt;Delete&lt;/a&gt;&lt;/td--&gt;
      &lt;form method="get" th:action="@{/edit(personId=${person.personId})}"&gt;
          &lt;button type="submit" name="submit" value="value"&gt;Edit&lt;/button&gt;
      &lt;/form&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>Where I have a link and a form for testing.</p>
  
  <p>The controller method to be called is:</p>
  
  <pre><code>// Gets a Person.
  @RequestMapping(value="/edit", method=RequestMethod.GET)
  public String getEditPerson(@RequestParam("personId") String personId, Model model) {
      logger.info(PersonController.class.getName() + ".getEditPerson() method called."); 
  
      Person person = personDAO.get(Integer.parseInt(personId));
      model.addAttribute("person", person);
  
      // Set view.      
      return "/edit";
  }    
  </code></pre>
  
  <p>The error when the button version of GET is called is:</p>
  
  <pre><code>Whitelabel Error Page
  
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  Sun Jul 24 00:26:16 BST 2016
  There was an unexpected error (type=Bad Request, status=400).
  Required String parameter 'personId' is not present`
  </code></pre>
  
  <p>I am using GET to trigger editing because no data is sent to the server here other than the personId. No database action is taken so it should be a GET.</p>