Вот фактический код:
@RequestMapping(value = "/competitors/{id}", method = RequestMethod.GET)
public Competitor getCompetitor(@PathVariable("id") long id)
{
Competitor competitor = competitorService.getCompetitorById(id);
if (null == competitor)
{
EmptyResultDataAccessException e = new EmptyResultDataAccessException(1);
logger.log(Level.WARN, e.getMessage());
throw e;
}
return competitor;
}
@RequestMapping(value = "/competitors/{id}", method = RequestMethod.DELETE)
public String deleteCompetitor(@PathVariable("id") long id)
{
Competitor competitor = new Competitor();
competitor.setId(id);
competitorService.deleteCompetitor(competitor);
return "Solid gone!";
}
Отправка запроса DELETE/конкурентам/200 приводит к ошибке:
"HTTP Status 405 - Метод запроса" DELETE "не поддерживается"
Запись из Spring подтверждает, что путь к этому методу не найден:
5559 [tomcat-http--3] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing DELETE request for [/vrsboserver/competitors/200] 5562 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping
- Matching patterns for request [/competitors/200] are [/competitors/{id}] 5565 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping
- Mapping [/competitors/200] to handler '[email protected]' 5565 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.WebContentInterceptor - Looking up cache seconds for [/competitors/200] 5565 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.WebContentInterceptor - Applying default cache seconds to [/competitors/200] 5566 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver
- Resolving exception from handler [[email protected]]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not supported 5567 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver
- Resolving exception from handler [[email protected]]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not supported 5568 [tomcat-http--3] DEBUG org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
- Resolving exception from handler [[email protected]]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not supported 5568 [tomcat-http--3] WARN org.springframework.web.servlet.PageNotFound - Request method 'DELETE' not supported
На что мой ответ "BUH?".