Package org.springframework.web.bind

# Class ServletRequestBindingException

java.lang.Object
java.lang.Throwable
java.lang.Exception
jakarta.servlet.ServletException
org.springframework.web.bind.ServletRequestBindingException

All Implemented Interfaces:
  `Serializable`, `ErrorResponse`

Direct Known Subclasses:
  `MissingRequestValueException`, `UnsatisfiedServletRequestParameterException`

public class ServletRequestBindingException extends ServletException implements ErrorResponse
Fatal binding exception, thrown when we want to treat binding exceptions as unrecoverable.

Extends ServletException for convenient throwing in any Servlet resource (such as a Filter), and NestedServletException for proper root cause handling (as the plain ServletException doesn't expose its root cause at all).

Author:
  Rod Johnson, Juergen Hoeller
See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.springframework.web.ErrorResponse

`ErrorResponse.Builder, ErrorResponse.Interceptor`

## Constructor Summary

Constructors
Modifier
Constructor
Description
``
`ServletRequestBindingException(String msg)`
Constructor with a message only.
`protected`
`ServletRequestBindingException(String msg, String messageDetailCode, Object[] messageDetailArguments)`
Constructor for ServletRequestBindingException.
``
`ServletRequestBindingException(String msg, Throwable cause)`
Constructor with a message and a cause.
`protected`
`ServletRequestBindingException(String msg, Throwable cause, String messageDetailCode, Object[] messageDetailArguments)`
Constructor for ServletRequestBindingException.

## Method Summary

Modifier and Type
Method
Description
`ProblemDetail`
`getBody()`
Return the body for the response, formatted as an RFC 9457 `ProblemDetail` whose `status` should match the response status.
`Object[]`
`getDetailMessageArguments()`
Return arguments to use along with a `message code` to resolve the problem "detail" for this exception through a `MessageSource`.
`String`
`getDetailMessageCode()`
Return a code to use to resolve the problem "detail" for this exception through a `MessageSource`.
`HttpStatusCode`
`getStatusCode()`
Return the HTTP status code to use for the response.

### Methods inherited from class jakarta.servlet.ServletException

`getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.web.ErrorResponse

`getDetailMessageArguments, getHeaders, getTitleMessageCode, getTypeMessageCode, updateAndGetBody`

## Constructor Details

### ServletRequestBindingException

public ServletRequestBindingException(@Nullable String msg)
Constructor with a message only.

Parameters:
  `msg` - the detail message

### ServletRequestBindingException

public ServletRequestBindingException(@Nullable String msg, @Nullable Throwable cause)
Constructor with a message and a cause.

Parameters:
  `msg` - the detail message
  `cause` - the root cause

### ServletRequestBindingException

protected ServletRequestBindingException(@Nullable String msg, @Nullable String messageDetailCode, @Nullable Object[] messageDetailArguments)
Constructor for ServletRequestBindingException.

Parameters:
  `msg` - the detail message
  `messageDetailCode` - the code to use to resolve the problem "detail" through a `MessageSource`
  `messageDetailArguments` - the arguments to make available when resolving the problem "detail" through a `MessageSource`
Since:
  6.0

### ServletRequestBindingException

protected ServletRequestBindingException(@Nullable String msg, @Nullable Throwable cause, @Nullable String messageDetailCode, @Nullable Object[] messageDetailArguments)
Constructor for ServletRequestBindingException.

Parameters:
  `msg` - the detail message
  `cause` - the root cause
  `messageDetailCode` - the code to use to resolve the problem "detail" through a `MessageSource`
  `messageDetailArguments` - the arguments to make available when resolving the problem "detail" through a `MessageSource`
Since:
  6.0

## Method Details

### getStatusCode

public HttpStatusCode getStatusCode()
Description copied from interface: `ErrorResponse`
Return the HTTP status code to use for the response.

Specified by:
  `getStatusCode` in interface `ErrorResponse`

### getBody

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

Note: The returned `ProblemDetail` may be updated before the response is rendered, for example, via `ErrorResponse.updateAndGetBody(MessageSource, Locale)`. Therefore, implementing methods should use an instance field, and should not re-create the `ProblemDetail` on every call, nor use a static variable.

Specified by:
  `getBody` in interface `ErrorResponse`

### getDetailMessageCode

public String getDetailMessageCode()
Description copied from interface: `ErrorResponse`
Return a code to use to resolve the problem "detail" for this exception through a `MessageSource`.

By default this is initialized via `ErrorResponse.getDefaultDetailMessageCode(Class, String)`.

Specified by:
  `getDetailMessageCode` in interface `ErrorResponse`

### getDetailMessageArguments

@Nullable public Object[] getDetailMessageArguments()
Description copied from interface: `ErrorResponse`
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, for example, "Invalid content type {0}".

Specified by:
  `getDetailMessageArguments` in interface `ErrorResponse`