类 ResponseStatusException
- java.lang.Object
- java.lang.Throwable
- java.lang.Exception
- java.lang.RuntimeException
- org.springframework.core.NestedRuntimeException
- org.springframework.web.server.ResponseStatusException
- 所有已实现的接口:
Serializable
- 直接已知子类:
MediaTypeNotSupportedStatusException
,MethodNotAllowedException
,NotAcceptableStatusException
,ServerErrorException
,ServerWebInputException
,UnsupportedMediaTypeStatusException
public class ResponseStatusException extends NestedRuntimeException
Base class for exceptions associated with specific HTTP response status codes.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
- 另请参阅:
- 序列化表格
构造器概要
构造器 构造器 说明 ResponseStatusException(HttpStatus status)
Constructor with a response status.ResponseStatusException(HttpStatus status, String reason)
Constructor with a response status and a reason to add to the exception message as explanation.ResponseStatusException(HttpStatus status, String reason, Throwable cause)
Constructor with a response status and a reason to add to the exception message as explanation, as well as a nested exception.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 Map<String,String>
getHeaders()
已过时。as of 5.1.13 in favor ofgetResponseHeaders()
String
getMessage()
Return the detail message, including the message from the nested exception if there is one.String
getReason()
The reason explaining the exception (potentiallynull
or empty).HttpHeaders
getResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g.HttpStatus
getStatus()
Return the HTTP status associated with this exception.从类继承的方法 org.springframework.core.NestedRuntimeException
contains, getMostSpecificCause, getRootCause
构造器详细资料
ResponseStatusException
public ResponseStatusException(HttpStatus status)
Constructor with a response status.- 参数:
status
- the HTTP status (required)
ResponseStatusException
public ResponseStatusException(HttpStatus status, @Nullable String reason)
Constructor with a response status and a reason to add to the exception message as explanation.- 参数:
status
- the HTTP status (required)reason
- the associated reason (optional)
ResponseStatusException
public ResponseStatusException(HttpStatus status, @Nullable String reason, @Nullable Throwable cause)
Constructor with a response status and a reason to add to the exception message as explanation, as well as a nested exception.- 参数:
status
- the HTTP status (required)reason
- the associated reason (optional)cause
- a nested exception (optional)
方法详细资料
getStatus
public HttpStatus getStatus()
Return the HTTP status associated with this exception.
getHeaders
@Deprecated public Map<String,String> getHeaders()
已过时。as of 5.1.13 in favor ofgetResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g. "Allow", "Accept", etc.The default implementation in this class returns an empty map.
- 从以下版本开始:
- 5.1.11
getResponseHeaders
public HttpHeaders getResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g. "Allow", "Accept", etc.The default implementation in this class returns empty headers.
- 从以下版本开始:
- 5.1.13
getReason
@Nullable public String getReason()
The reason explaining the exception (potentiallynull
or empty).
getMessage
public String getMessage()
从类复制的说明:NestedRuntimeException
Return the detail message, including the message from the nested exception if there is one.- 覆盖:
getMessage
在类中NestedRuntimeException