List of usage examples for org.springframework.web HttpRequestMethodNotSupportedException getSupportedHttpMethods
@Nullable
public Set<HttpMethod> getSupportedHttpMethods()
From source file:cz.jirutka.spring.exhandler.handlers.HttpRequestMethodNotSupportedExceptionHandler.java
@Override protected HttpHeaders createHeaders(HttpRequestMethodNotSupportedException ex, HttpServletRequest req) { HttpHeaders headers = super.createHeaders(ex, req); if (!isEmpty(ex.getSupportedMethods())) { headers.setAllow(ex.getSupportedHttpMethods()); }/*from w w w. j a va 2 s .co m*/ return headers; }
From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandler.java
protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { Set<HttpMethod> supportedMethods = ex.getSupportedHttpMethods(); if (!supportedMethods.isEmpty()) { headers.setAllow(supportedMethods); }/*from w ww . j a v a2 s.c o m*/ return errorResponse("methodNotAllowed", headers); }
From source file:org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler.java
/** * Customize the response for HttpRequestMethodNotSupportedException. * <p>This method logs a warning, sets the "Allow" header, and delegates to * {@link #handleExceptionInternal}.//from w ww . j av a2 s . c o m * @param ex the exception * @param headers the headers to be written to the response * @param status the selected response status * @param request the current request * @return a {@code ResponseEntity} instance */ protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { pageNotFoundLogger.warn(ex.getMessage()); Set<HttpMethod> supportedMethods = ex.getSupportedHttpMethods(); if (!CollectionUtils.isEmpty(supportedMethods)) { headers.setAllow(supportedMethods); } return handleExceptionInternal(ex, null, headers, status, request); }