title: Thymeleaf send parameter from html to controller
body: <p>I'm newbie in Thymeleaf. I'm trying to create simple crud application. I'm trying to delete object of Customer class on delete button. How can I set parameter(for example - id) to the method which called deleteUser using Thymeleaf. Here's my controller.</p>
  
  <pre><code>package controllers;
  
  //imports
  
  
  @Controller
  public class WebController extends WebMvcConfigurerAdapter {
  
      @Autowired
      private CustomerDAO customerDAO;
  
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/results").setViewName("results");
      }
  
      //show all users
      @RequestMapping(value="/users", method=RequestMethod.GET)
      public String contacts(Model model) {
          model.addAttribute("users",customerDAO.findAll());
          return "list";
      }
  
      //show form
      @RequestMapping(value="/users/add", method=RequestMethod.GET)
      public String showForm(Customer customer) {
          return "form";
      }
  
      //add user
      @RequestMapping(value="/users/doAdd", method=RequestMethod.POST)
      public String addUser(@RequestParam("firstName") String firstName,
                             @RequestParam("lastName") String lastName,
                             @RequestParam("lastName") String email) {
          customerDAO.save(new Customer(firstName, lastName, email));
          return "redirect:/users";
      }
  
      //delete user
      @RequestMapping(value="users/doDelete/{id}", method = RequestMethod.POST)
      public String deleteUser (@PathVariable Long id) {
          customerDAO.delete(id);
          return "redirect:/users";
      }
  }
  </code></pre>
  
  <p>Here's my view.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;title&gt;Getting Started: Serving Web Content&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  List of users
  &lt;a href="users/add"&gt;Add new user&lt;/a&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Id&lt;/th&gt;
          &lt;th&gt;First Name&lt;/th&gt;
          &lt;th&gt;Last Name&lt;/th&gt;
          &lt;th&gt;Email&lt;/th&gt;
          &lt;th&gt;Action&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr th:each="user : ${users}"&gt;
          &lt;td th:text="${user.id}"&gt;Id&lt;/td&gt;
          &lt;td th:text="${user.firstName}"&gt;First name&lt;/td&gt;
          &lt;td th:text="${user.lastName}"&gt;Last Name&lt;/td&gt;
          &lt;td th:text="${user.email}"&gt;Email&lt;/td&gt;
          &lt;td&gt;
              &lt;form th:action="@{/users/doDelete/}" th:object="${customer}" method="post"&gt;
                  &lt;button type="submit"&gt;Delete&lt;/button&gt;
              &lt;/form&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>