Skip to content

How to send PUT/PATCH/DELETE requests in thymeleaf template?

How can I send a DELETE request with thymeleaf? I tried as follows:

<form action="" th:method="delete">
    <input type="submit" class="btn btn-primary" href="/person/123" value="Delete" />

@RequestMapping(value="/person/{id}", method = RequestMethod.DELETE)
public String delete(@PathVariable String id) {
    return "Successfully deleted";

But all that I get is: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported


If you are using Spring Boot 2.2+, you need to enable support for this explictly. Add the following to


Spring Boot < 2.2 always registers the filter, for Spring Boot 2.2 or higher you need to set the property.

Tip: You can replace @RequestMapping(value="/person/{id}", method = RequestMethod.DELETE) with @DeleteMapping("/person/{id}")