title: How to handle RESTful delete in Spring MVC
body: <p>How do I correctly use RESTful delete in Spring MVC controller? I have DAO that returns boolean when trying to delete some item. </p>
  
  <p>I am trying to delete item. If everything was OK, just show list of items (deleted item won't be there anymore). If item cannot be removed, redirect to details page and say why it couldn't be deleted.</p>
  
  <p>Do I need some special response status or something like this? Is my approach RESTful?</p>
  
  <pre><code>@RequestMapping(value = "items/{id}", method = RequestMethod.DELETE)
  public String delete(@PathVariable("id") int itemId, Model model) {
      Item item = itemDao.get(id);
  
      // true -&gt; can delete
      // false -&gt; cannot delete, f.e. is FK reference somewhere
      boolean wasOk = itemDao.delete(item); 
  
      if (wasOk) {
          return "redirect:/items";
      }
  
      // will write to user which item couldn't be deleted
      model.addAttribute("item", item);
      return "items/error";
  }
  </code></pre>