Class HttpRequestMethodNotSupportedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
jakarta.servlet.ServletException
org.springframework.web.HttpRequestMethodNotSupportedException
All Implemented Interfaces:
Serializable, ErrorResponse

public class HttpRequestMethodNotSupportedException extends ServletException implements ErrorResponse
Exception thrown when a request handler does not support a specific request method.
Since:
2.0
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • HttpRequestMethodNotSupportedException

      public HttpRequestMethodNotSupportedException(String method)
      Create a new HttpRequestMethodNotSupportedException.
      Parameters:
      method - the unsupported HTTP request method
    • HttpRequestMethodNotSupportedException

      public HttpRequestMethodNotSupportedException(String method, String msg)
      Create a new HttpRequestMethodNotSupportedException.
      Parameters:
      method - the unsupported HTTP request method
      msg - the detail message
    • HttpRequestMethodNotSupportedException

      public HttpRequestMethodNotSupportedException(String method, @Nullable Collection<String> supportedMethods)
      Create a new HttpRequestMethodNotSupportedException.
      Parameters:
      method - the unsupported HTTP request method
      supportedMethods - the actually supported HTTP methods (may be null)
    • HttpRequestMethodNotSupportedException

      public HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods)
      Create a new HttpRequestMethodNotSupportedException.
      Parameters:
      method - the unsupported HTTP request method
      supportedMethods - the actually supported HTTP methods (may be null)
    • HttpRequestMethodNotSupportedException

      public HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods, String msg)
      Create a new HttpRequestMethodNotSupportedException.
      Parameters:
      method - the unsupported HTTP request method
      supportedMethods - the actually supported HTTP methods
      msg - the detail message
  • Method Details

    • getMethod

      public String getMethod()
      Return the HTTP request method that caused the failure.
    • getSupportedMethods

      @Nullable public String[] getSupportedMethods()
      Return the actually supported HTTP methods, or null if not known.
    • getSupportedHttpMethods

      @Nullable public Set<HttpMethod> getSupportedHttpMethods()
      Return the actually supported HTTP methods as HttpMethod instances, or null if not known.
      Since:
      3.2
    • getRawStatusCode

      public int getRawStatusCode()
      Description copied from interface: ErrorResponse
      Return the HTTP status value for the response, potentially non-standard and not resolvable via HttpStatus.
      Specified by:
      getRawStatusCode in interface ErrorResponse
    • getHeaders

      public HttpHeaders getHeaders()
      Description copied from interface: ErrorResponse
      Return headers to use for the response.
      Specified by:
      getHeaders in interface ErrorResponse
    • getBody

      public ProblemDetail getBody()
      Description copied from interface: ErrorResponse
      Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.
      Specified by:
      getBody in interface ErrorResponse