Top Description Fields Constructors Methods
org.springframework.web

public Class HttpRequestMethodNotSupportedException

extends ServletException
implements ErrorResponse
Class Inheritance
All Implemented Interfaces
org.springframework.web.ErrorResponse
Annotations
@SuppressWarnings:serial
Imports
java.util.Collection, .LinkedHashSet, .Set, jakarta.servlet.ServletException, org.springframework.http.HttpHeaders, .HttpMethod, .HttpStatus, .HttpStatusCode, .ProblemDetail, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, .StringUtils

Exception thrown when a request handler does not support a specific request method.
Authors
Juergen Hoeller, Sam Brannen
Since
2.0

Field Summary

Modifier and TypeField and Description
private final ProblemDetail
private final String
private final String[]

Constructor Summary

AccessConstructor and Description
public
HttpRequestMethodNotSupportedException(String
the unsupported HTTP request method
method
)

Create a new HttpRequestMethodNotSupportedException.

public
HttpRequestMethodNotSupportedException(String
the unsupported HTTP request method
method
,
Collection<String>
the actually supported HTTP methods (possibly null)
supportedMethods
)

Create a new HttpRequestMethodNotSupportedException.

private
HttpRequestMethodNotSupportedException(String
the unsupported HTTP request method
method
,
String[]
the actually supported HTTP methods (possibly null)
supportedMethods
)

Create a new HttpRequestMethodNotSupportedException.

Method Summary

Modifier and TypeMethod and Description
public ProblemDetail
getBody()

Implements org.springframework.web.ErrorResponse.getBody.

Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.
public Object[]
getDetailMessageArguments()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageArguments.

Return arguments to use along with a message code to resolve the problem "detail" for this exception through a MessageSource.
public HttpHeaders
getHeaders()

Overrides default org.springframework.web.ErrorResponse.getHeaders.

Return headers to use for the response.
public String
getMethod()

Return the HTTP request method that caused the failure.

public HttpStatusCode
getStatusCode()

Implements org.springframework.web.ErrorResponse.getStatusCode.

Return the HTTP status code to use for the response.
public Set<HttpMethod>
getSupportedHttpMethods()

Return the actually supported HTTP methods as HttpMethod instances, or null if not known.

public String[]
getSupportedMethods()

Return the actually supported HTTP methods, or null if not known.

Inherited from jakarta.servlet.ServletException:
getRootCause

Field Detail

bodyback to summary
private final ProblemDetail body
methodback to summary
private final String method
supportedMethodsback to summary
private final String[] supportedMethods
Annotations
@Nullable

Constructor Detail

HttpRequestMethodNotSupportedExceptionback to summary
public HttpRequestMethodNotSupportedException(String method)

Create a new HttpRequestMethodNotSupportedException.

Parameters
method:String

the unsupported HTTP request method

HttpRequestMethodNotSupportedExceptionback to summary
public HttpRequestMethodNotSupportedException(String method, Collection<String> supportedMethods)

Create a new HttpRequestMethodNotSupportedException.

Parameters
method:String

the unsupported HTTP request method

supportedMethods:Collection<String>

the actually supported HTTP methods (possibly null)

HttpRequestMethodNotSupportedExceptionback to summary
private HttpRequestMethodNotSupportedException(String method, String[] supportedMethods)

Create a new HttpRequestMethodNotSupportedException.

Parameters
method:String

the unsupported HTTP request method

supportedMethods:String[]

the actually supported HTTP methods (possibly null)

Method Detail

getBodyback to summary
public ProblemDetail getBody()

Implements org.springframework.web.ErrorResponse.getBody.

Doc from org.springframework.web.ErrorResponse.getBody.

Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.

Annotations
@Override
getDetailMessageArgumentsback to summary
public Object[] getDetailMessageArguments()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageArguments.

Doc from org.springframework.web.ErrorResponse.getDetailMessageArguments.

Return arguments to use along with a message code to resolve the problem "detail" for this exception through a MessageSource. The arguments are expanded into placeholders of the message value, e.g. "Invalid content type {0}".

Annotations
@Override
getHeadersback to summary
public HttpHeaders getHeaders()

Overrides default org.springframework.web.ErrorResponse.getHeaders.

Doc from org.springframework.web.ErrorResponse.getHeaders.

Return headers to use for the response.

Annotations
@Override
getMethodback to summary
public String getMethod()

Return the HTTP request method that caused the failure.

getStatusCodeback to summary
public HttpStatusCode getStatusCode()

Implements org.springframework.web.ErrorResponse.getStatusCode.

Doc from org.springframework.web.ErrorResponse.getStatusCode.

Return the HTTP status code to use for the response.

Annotations
@Override
getSupportedHttpMethodsback to summary
public Set<HttpMethod> getSupportedHttpMethods()

Return the actually supported HTTP methods as HttpMethod instances, or null if not known.

Annotations
@Nullable
Since
3.2
getSupportedMethodsback to summary
public String[] getSupportedMethods()

Return the actually supported HTTP methods, or null if not known.

Annotations
@Nullable