title: Spring says that Request method 'DELETE' not supported, when trying to delete database item
body: <p>I'm working on a school project, where you add Todo-items to database, show them, and grant user acces to individual pages created to each item. I'm using Spring and my Delete button nor individual pages showing specific task aren't working. In this project we use JPA to handle database.</p>
  
  <p>Heres my TodoItemDatabaseController:</p>
  
  <pre><code>package wad.tododatabase;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.DeleteMapping;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  
  @Controller
  public class TodoItemDatabaseController {
  
      @Autowired
      private TodoRepository todoRepository;
  
      @GetMapping("/")
      public String home(Model model) {
          model.addAttribute
          ("items", this.todoRepository.findAll());
          return "index";
      }
  </code></pre>
  
  <p>Here is the Delete that is not working.</p>
  
  <pre><code>    @DeleteMapping("/{itemId}")
      public String remove(Model model, @PathVariable Long itemId) {
          this.todoRepository.delete(this.todoRepository.getOne(itemId));
          return "redirect:/";
      }
  
  
      @PostMapping("/")
      public String post(@RequestParam String name) {
          if (!name.trim().isEmpty()) {
              TodoItem item = new TodoItem(name);
              todoRepository.save(item);
          }
  
          return "redirect:/";
      }
  </code></pre>
  
  <p>Here I'm trying to get specific id, to create individual page for the item.</p>
  
  <pre><code>    @GetMapping("/{id}")
      public String findOne(Model model, @PathVariable Long id) {
          TodoItem t1 = todoRepository.getOne(id);
          t1.count();
          model.addAttribute("item", t1);
          return "item"; 
      }
  
  
  }
  </code></pre>
  
  <p>Here are my html files. I post the DELETE part of the index.html file, and item.html, which is the page of individual to-do item.</p>
  
  <p>Index.html:</p>
  
  <pre><code>&lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;Task name&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
              &lt;/tr&gt;
  
              &lt;tr th:each="item : ${items}"&gt;
                  &lt;td&gt;&lt;a th:href="@{/{item}(item=${item.id})}" th:text="${item.name}"&gt;Item name&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form th:action="@{/{item}(item=${item.id})}" th:method="DELETE"&gt;&lt;input type="submit" value="Done!"/&gt;&lt;/form&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  </code></pre>
  
  <p>Item.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"&gt;
      &lt;head&gt;
          &lt;title&gt;TodoDatabase&lt;/title&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;h1 th:text="${item.name}"&gt;item name&lt;/h1&gt;
  
          &lt;p&gt;Item has been checked a total of &lt;span th:text="${item.checked}"&gt;-1&lt;/span&gt; times.&lt;/p&gt;
  
          &lt;a th:href="@{/}"&gt;Back to listing.&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Spring also gives 2 WARN statments, I guess they are warnings:</p>
  
  <pre><code>2017-11-13 21:52:13.902  WARN 29312 --- [nio-8080-exec-4] o.s.web.servlet.PageNotFound             : Request method 'DELETE' not supported
  2017-11-13 21:52:13.903  WARN 29312 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not supported
  </code></pre>
  
  <p>Here is my TodoRepository interface:</p>
  
  <pre><code>package wad.tododatabase;
  
  /**
   *
   * @author riku
   * 
   */
  import org.springframework.data.jpa.repository.JpaRepository;
  
  public interface TodoRepository extends JpaRepository&lt;TodoItem, Long&gt; {
  
  
  }
  </code></pre>
  
  <p>Any advice how to get this work?</p>