クラス ResponseEntityExceptionHandler
- 実装されているすべてのインターフェース:
Aware, MessageSourceAware
ResponseEntity を返すことで、Spring MVC で発生したすべての例外を処理する @ExceptionHandler メソッドを持つクラス。 アプリケーションでのグローバルな例外処理のための @ControllerAdvice の基本クラスとして便利です。サブクラスは、特定の例外を処理する個々のメソッドをオーバーライドしたり、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest) をオーバーライドしてすべての例外の共通処理をオーバーライドしたり、createResponseEntity(Object, HttpHeaders, HttpStatusCode, WebRequest) をオーバーライドして、選択した HTTP ステータスコード、ヘッダー、本文から ResponseEntity を作成する最終ステップをインターセプトしたりできます。
- 導入:
- 3.2
- 作成者:
- Rossen Stoyanchev
フィールドのサマリー
フィールド修飾子と型フィールド説明protected final org.apache.commons.logging.Logサブクラスで使用する共通のロガー。static final StringSEリクエストに対してマップされたハンドラーが見つからない場合に使用するログカテゴリ。protected static final org.apache.commons.logging.Logリクエストに対してマッピングされたハンドラーが見つからない場合に使用する特定のロガー。コンストラクターの概要
コンストラクター方法の概要
修飾子と型メソッド説明protected ProblemDetailcreateProblemDetail(ExceptionSE ex, HttpStatusCode status, StringSE defaultDetail, @Nullable StringSE detailMessageCode, ObjectSE @Nullable [] detailMessageArguments, WebRequest request) protected ResponseEntity<ObjectSE> createResponseEntity(@Nullable ObjectSE body, HttpHeaders headers, HttpStatusCode statusCode, WebRequest request) 指定された本文、ヘッダー、statusCode から使用するResponseEntityを作成します。protected @Nullable MessageSourceこの例外ハンドラーが使用するMessageSourceを取得します。protected @Nullable ResponseEntity<ObjectSE> AsyncRequestNotUsableExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) AsyncRequestTimeoutExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ConversionNotSupportedExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleErrorResponseException(ErrorResponseException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ErrorResponseExceptionの処理をカスタマイズします。final @Nullable ResponseEntity<ObjectSE> handleException(ExceptionSE ex, WebRequest request) リクエストの Spring MVC 処理内で発生したすべての例外を処理します。protected @Nullable ResponseEntity<ObjectSE> handleExceptionInternal(ExceptionSE ex, @Nullable ObjectSE body, HttpHeaders headers, HttpStatusCode statusCode, WebRequest request) 共通の処理とResponseEntityの作成のために、このクラスの他のすべてが委譲する内部ハンドラーメソッド。protected @Nullable ResponseEntity<ObjectSE> handleHandlerMethodValidationException(HandlerMethodValidationException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HandlerMethodValidationExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMediaTypeNotAcceptableExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMediaTypeNotSupportedExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMessageNotReadableExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMessageNotWritableExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpRequestMethodNotSupportedExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MaxUploadSizeExceededExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MethodArgumentNotValidExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMethodValidationException(MethodValidationException ex, HttpHeaders headers, HttpStatus status, WebRequest request) MethodValidationExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingPathVariableExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingServletRequestParameterExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingServletRequestPartExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) NoHandlerFoundExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleNoResourceFoundException(NoResourceFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) NoResourceFoundExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ServletRequestBindingExceptionの処理をカスタマイズします。protected @Nullable ResponseEntity<ObjectSE> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) TypeMismatchExceptionの処理をカスタマイズします。voidsetMessageSource(MessageSource messageSource) このオブジェクトが実行されるMessageSourceを設定します。
フィールドの詳細
PAGE_NOT_FOUND_LOG_CATEGORY
リクエストに対してマップされたハンドラーが見つからない場合に使用するログカテゴリ。- 関連事項:
pageNotFoundLogger
protected static final org.apache.commons.logging.Log pageNotFoundLoggerリクエストに対してマッピングされたハンドラーが見つからない場合に使用する特定のロガー。- 関連事項:
logger
protected final org.apache.commons.logging.Log loggerサブクラスで使用する共通のロガー。
コンストラクターの詳細
ResponseEntityExceptionHandler
public ResponseEntityExceptionHandler()
メソッドの詳細
setMessageSource
インターフェースからコピーされた説明:MessageSourceAwareこのオブジェクトが実行されるMessageSourceを設定します。通常の Bean プロパティの設定後、InitializingBean の afterPropertiesSet などの init コールバックやカスタム init メソッドの前に呼び出されます。ApplicationContextAware の setApplicationContext の前に呼び出されます。
- 次で指定:
- インターフェース
MessageSourceAwareのsetMessageSource - パラメーター:
messageSource- このオブジェクトが使用するメッセージソース
getMessageSource
handleException
@ExceptionHandler({HttpRequestMethodNotSupportedException.class,HttpMediaTypeNotSupportedException.class,HttpMediaTypeNotAcceptableException.class,MissingPathVariableException.class,MissingServletRequestParameterException.class,MissingServletRequestPartException.class,ServletRequestBindingException.class,MethodArgumentNotValidException.class,HandlerMethodValidationException.class,NoHandlerFoundException.class,NoResourceFoundException.class,AsyncRequestTimeoutException.class,ErrorResponseException.class,MaxUploadSizeExceededException.class,ConversionNotSupportedException.class,TypeMismatchException.class,HttpMessageNotReadableException.class,HttpMessageNotWritableException.class,MethodValidationException.class,AsyncRequestNotUsableException.class}) public final @Nullable ResponseEntity<ObjectSE> handleException(ExceptionSE ex, WebRequest request) throws ExceptionSE リクエストの Spring MVC 処理内で発生したすべての例外を処理します。- パラメーター:
ex- 処理する例外request- 現在のリクエスト- 例外:
ExceptionSE
handleHttpRequestMethodNotSupported
protected @Nullable ResponseEntity<ObjectSE> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpRequestMethodNotSupportedExceptionの処理をカスタマイズします。このメソッドは警告をログに記録し、
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleHttpMediaTypeNotSupported
protected @Nullable ResponseEntity<ObjectSE> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMediaTypeNotSupportedExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleHttpMediaTypeNotAcceptable
protected @Nullable ResponseEntity<ObjectSE> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMediaTypeNotAcceptableExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleMissingPathVariable
protected @Nullable ResponseEntity<ObjectSE> handleMissingPathVariable(MissingPathVariableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingPathVariableExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 4.2
handleMissingServletRequestParameter
protected @Nullable ResponseEntity<ObjectSE> handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingServletRequestParameterExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleMissingServletRequestPart
protected @Nullable ResponseEntity<ObjectSE> handleMissingServletRequestPart(MissingServletRequestPartException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MissingServletRequestPartExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleServletRequestBindingException
protected @Nullable ResponseEntity<ObjectSE> handleServletRequestBindingException(ServletRequestBindingException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ServletRequestBindingExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleMethodArgumentNotValid
protected @Nullable ResponseEntity<ObjectSE> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MethodArgumentNotValidExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに書き込まれるヘッダーstatus- 選択したレスポンスステータスrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleHandlerMethodValidationException
protected @Nullable ResponseEntity<ObjectSE> handleHandlerMethodValidationException(HandlerMethodValidationException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HandlerMethodValidationExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに書き込まれるヘッダーstatus- 選択したレスポンスステータスrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.1
handleNoHandlerFoundException
protected @Nullable ResponseEntity<ObjectSE> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) NoHandlerFoundExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 4.0
handleNoResourceFoundException
protected @Nullable ResponseEntity<ObjectSE> handleNoResourceFoundException(NoResourceFoundException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) NoResourceFoundExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.1
handleAsyncRequestTimeoutException
protected @Nullable ResponseEntity<ObjectSE> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) AsyncRequestTimeoutExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 4.2.8
handleErrorResponseException
protected @Nullable ResponseEntity<ObjectSE> handleErrorResponseException(ErrorResponseException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ErrorResponseExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.0
handleMaxUploadSizeExceededException
protected @Nullable ResponseEntity<ObjectSE> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) MaxUploadSizeExceededExceptionの処理をカスタマイズします。このメソッドは
handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.1
handleConversionNotSupported
protected @Nullable ResponseEntity<ObjectSE> handleConversionNotSupported(ConversionNotSupportedException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) ConversionNotSupportedExceptionの処理をカスタマイズします。デフォルトでは、このメソッドはステータスと短い詳細メッセージを含む
ProblemDetailを作成し、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲する前にMessageSourceを介して詳細のオーバーライドを検索します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleTypeMismatch
protected @Nullable ResponseEntity<ObjectSE> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) TypeMismatchExceptionの処理をカスタマイズします。デフォルトでは、このメソッドはステータスと短い詳細メッセージを含む
ProblemDetailを作成し、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲する前に、MessageSourceを介して詳細のオーバーライドを検索します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleHttpMessageNotReadable
protected @Nullable ResponseEntity<ObjectSE> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMessageNotReadableExceptionの処理をカスタマイズします。デフォルトでは、このメソッドはステータスと短い詳細メッセージを含む
ProblemDetailを作成し、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲する前にMessageSourceを介して詳細のオーバーライドを検索します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleHttpMessageNotWritable
protected @Nullable ResponseEntity<ObjectSE> handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) HttpMessageNotWritableExceptionの処理をカスタマイズします。デフォルトでは、このメソッドはステータスと短い詳細メッセージを含む
ProblemDetailを作成し、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲する前にMessageSourceを介して詳細のオーバーライドを検索します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
handleMethodValidationException
protected @Nullable ResponseEntity<ObjectSE> handleMethodValidationException(MethodValidationException ex, HttpHeaders headers, HttpStatus status, WebRequest request) MethodValidationExceptionの処理をカスタマイズします。デフォルトでは、このメソッドはステータスと短い詳細メッセージを含む
ProblemDetailを作成し、handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatusCode, WebRequest)に委譲する前にMessageSourceを介して詳細のオーバーライドを検索します。- パラメーター:
ex- 処理する例外headers- レスポンスに使用するヘッダーstatus- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.1
handleAsyncRequestNotUsableException
protected @Nullable ResponseEntity<ObjectSE> handleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex, WebRequest request) AsyncRequestNotUsableExceptionの処理をカスタマイズします。デフォルトでは、レスポンスが使用できないため、
nullを返します。- パラメーター:
ex- 処理する例外request- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります - 導入:
- 6.2
createProblemDetail
protected ProblemDetail createProblemDetail(ExceptionSE ex, HttpStatusCode status, StringSE defaultDetail, @Nullable StringSE detailMessageCode, ObjectSE @Nullable [] detailMessageArguments, WebRequest request) - パラメーター:
ex- 処理中の例外status- 例外に関連付けるステータスdefaultDetail- 「詳細」フィールドのデフォルト値detailMessageCode-MessageSourceを通じて「詳細」フィールドを検索するために使用するコード。nullの場合、使用するデフォルトのメッセージコードを決定するためにErrorResponse.getDefaultDetailMessageCode(Class, String)が使用されます。detailMessageArguments- detailMessageCode の議論request- 現在のリクエスト- 戻り値:
- 作成された
ProblemDetailインスタンス - 導入:
- 6.0
handleExceptionInternal
protected @Nullable ResponseEntity<ObjectSE> handleExceptionInternal(ExceptionSE ex, @Nullable ObjectSE body, HttpHeaders headers, HttpStatusCode statusCode, WebRequest request) 共通の処理とResponseEntityの作成のために、このクラスの他のすべてが委譲する内部ハンドラーメソッド。デフォルトの実装では、次のことが行われます。
- レスポンスがすでにコミットされている場合は
nullを返す - レスポンスステータスが 500 (INTERNAL_SERVER_ERROR) の場合は、
"jakarta.servlet.error.exception"リクエスト属性を設定します。 bodyがnullの場合、ErrorResponse例外からbodyを抽出します。
- パラメーター:
ex- 処理する例外body- レスポンスに使用するボディheaders- レスポンスに使用するヘッダーstatusCode- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用するレスポンスの
ResponseEntity。レスポンスがすでにコミットされている場合はnullの可能性があります
- レスポンスがすでにコミットされている場合は
createResponseEntity
protected ResponseEntity<ObjectSE> createResponseEntity(@Nullable ObjectSE body, HttpHeaders headers, HttpStatusCode statusCode, WebRequest request) 指定された本文、ヘッダー、statusCode から使用するResponseEntityを作成します。サブクラスはこのメソッドをオーバーライドして、本文、ヘッダー、statusCode をインスペクションし、必要に応じて変更して、たとえば、ProblemDetailのインスタンスをProblemDetailの拡張として再作成することができます。- パラメーター:
body- レスポンスに使用するボディheaders- レスポンスに使用するヘッダーstatusCode- レスポンスに使用するステータスコードrequest- 現在のリクエスト- 戻り値:
- 使用する
ResponseEntityインスタンス - 導入:
- 6.0