Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported] code example

Example 1: thymeleaf Request method 'POST' not supportedorg.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported

// FOR DELETE METHODS THIS CONFIG MAY BE NECESSARY IN YOUR app.properties:

spring.mvc.hiddenmethod.filter.enabled=true

Example 2: Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported] on @DeleteMapping

@RequestMapping(value="/empdelete/{id}", method=RequestMethod.DELETE)
public void deleteEmployee( PathVariable(“id”) Long id) {
    collaborateurRepository.deleteById(id);
}
//method={RequestMethod.DELETE, RequestMethod.GET}
=> changing for this GET method works fine

Tags:

Misc Example