Top Description Fields Constructors Methods
org.springframework.web.bind

public Class ServletRequestBindingException

extends ServletException
implements ErrorResponse
Class Inheritance
All Implemented Interfaces
org.springframework.web.ErrorResponse
Known Direct Subclasses
org.springframework.web.bind.UnsatisfiedServletRequestParameterException, org.springframework.web.bind.MissingRequestValueException
Annotations
@SuppressWarnings:serial
Imports
jakarta.servlet.ServletException, org.springframework.http.HttpStatus, .HttpStatusCode, .ProblemDetail, org.springframework.lang.Nullable, org.springframework.web.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).

Authors
Rod Johnson, Juergen Hoeller

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
ServletRequestBindingException(String
the detail message
msg
)

Constructor with a message only.

public
ServletRequestBindingException(String
the detail message
msg
,
Throwable
the root cause
cause
)

Constructor with a message and a cause.

protected
ServletRequestBindingException(String
the detail message
msg
,
String
the code to use to resolve the problem "detail" through a org.springframework.context.MessageSource
messageDetailCode
,
Object[]
the arguments to make available when resolving the problem "detail" through a MessageSource
messageDetailArguments
)

Constructor for ServletRequestBindingException.

protected
ServletRequestBindingException(String
the detail message
msg
,
Throwable
the root cause
cause
,
String
the code to use to resolve the problem "detail" through a org.springframework.context.MessageSource
messageDetailCode
,
Object[]
the arguments to make available when resolving the problem "detail" through a MessageSource
messageDetailArguments
)

Constructor for ServletRequestBindingException.

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 String
getDetailMessageCode()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageCode.

Return a code to use to resolve the problem "detail" for this exception through a MessageSource.

public HttpStatusCode
getStatusCode()

Implements org.springframework.web.ErrorResponse.getStatusCode.

Return the HTTP status code to use for the response.

private String
initMessageDetailCode(String messageDetailCode)

Inherited from jakarta.servlet.ServletException:
getRootCause

Field Detail

bodyback to summary
private final ProblemDetail body
messageDetailArgumentsback to summary
private final Object[] messageDetailArguments
Annotations
@Nullable
messageDetailCodeback to summary
private final String messageDetailCode

Constructor Detail

ServletRequestBindingExceptionback to summary
public ServletRequestBindingException(String msg)

Constructor with a message only.

Parameters
msg:String

the detail message

ServletRequestBindingExceptionback to summary
public ServletRequestBindingException(String msg, Throwable cause)

Constructor with a message and a cause.

Parameters
msg:String

the detail message

cause:Throwable

the root cause

ServletRequestBindingExceptionback to summary
protected ServletRequestBindingException(String msg, String messageDetailCode, Object[] messageDetailArguments)

Constructor for ServletRequestBindingException.

Parameters
msg:String

the detail message

messageDetailCode:String

the code to use to resolve the problem "detail" through a org.springframework.context.MessageSource

messageDetailArguments:Object[]

the arguments to make available when resolving the problem "detail" through a MessageSource

Since
6.0
ServletRequestBindingExceptionback to summary
protected ServletRequestBindingException(String msg, Throwable cause, String messageDetailCode, Object[] messageDetailArguments)

Constructor for ServletRequestBindingException.

Parameters
msg:String

the detail message

cause:Throwable

the root cause

messageDetailCode:String

the code to use to resolve the problem "detail" through a org.springframework.context.MessageSource

messageDetailArguments:Object[]

the arguments to make available when resolving the problem "detail" through a MessageSource

Since
6.0

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
getDetailMessageCodeback to summary
public String getDetailMessageCode()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageCode.

Doc from org.springframework.web.ErrorResponse.getDetailMessageCode.

Return a code to use to resolve the problem "detail" for this exception through a MessageSource.

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

Annotations
@Override
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
initMessageDetailCodeback to summary
private String initMessageDetailCode(String messageDetailCode)