クラス DefaultHandlerExceptionResolver
- 実装されているすべてのインターフェース:
Ordered, HandlerExceptionResolver
HandlerExceptionResolver インターフェースのデフォルトの実装。 この例外リゾルバーは、一般的な Spring DispatcherServlet でデフォルトで有効になっています。
サポートされる例外
| 例外 | HTTP ステータスコード |
|---|---|
HttpRequestMethodNotSupportedException | 405 (SC_METHOD_NOT_ALLOWED) |
HttpMediaTypeNotSupportedException | 415 (SC_UNSUPPORTED_MEDIA_TYPE) |
HttpMediaTypeNotAcceptableException | 406 (SC_NOT_ACCEPTABLE) |
MissingPathVariableException | 500 (SC_INTERNAL_SERVER_ERROR) |
MissingServletRequestParameterException | 400 (SC_BAD_REQUEST) |
MissingServletRequestPartException | 400 (SC_BAD_REQUEST) |
ServletRequestBindingException | 400 (SC_BAD_REQUEST) |
ConversionNotSupportedException | 500 (SC_INTERNAL_SERVER_ERROR) |
TypeMismatchException | 400 (SC_BAD_REQUEST) |
HttpMessageNotReadableException | 400 (SC_BAD_REQUEST) |
HttpMessageNotWritableException | 500 (SC_INTERNAL_SERVER_ERROR) |
MethodArgumentNotValidException | 400 (SC_BAD_REQUEST) |
500 (SC_INTERNAL_SERVER_ERROR) | |
400 (SC_BAD_REQUEST) | |
NoHandlerFoundException | 404 (SC_NOT_FOUND) |
NoResourceFoundException | 404 (SC_NOT_FOUND) |
AsyncRequestTimeoutException | 503 (SC_SERVICE_UNAVAILABLE) |
AsyncRequestNotUsableException | 適用不可 |
- 導入:
- 3.0
- 作成者:
- Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller
- 関連事項:
フィールドのサマリー
フィールド修飾子と型フィールド説明static final StringSEリクエストに対してマップされたハンドラーが見つからない場合に使用するログカテゴリ。protected static final org.apache.commons.logging.Logリクエストに対してマップされたハンドラーが見つからない場合に使用する追加のロガー。クラス AbstractHandlerExceptionResolver から継承されたフィールド
loggerインターフェース Ordered から継承されたフィールド
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCEコンストラクターの概要
コンストラクター方法の概要
修飾子と型メソッド説明protected @Nullable ModelAndViewdoResolveException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler, ExceptionSE ex) ハンドラーの実行中にスローされた特定の例外を実際に解決し、適切であれば特定のエラーページを表すModelAndViewを返します。protected ModelAndViewhandleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) ServletOutputStream からの I/O 障害の場合に対処します。protected @Nullable ModelAndViewhandleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) 非同期リクエストがタイムアウトした場合を処理します。protected ModelAndViewhandleConversionNotSupported(ConversionNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) WebDataBinder変換が発生しないケースを処理します。protected ModelAndViewhandleDisconnectedClientException(ExceptionSE ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) クライアントが去ったことを示す例外を処理します。protected ModelAndViewhandleErrorResponse(ErrorResponse errorResponse, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) ErrorResponse例外を処理します。protected @Nullable ModelAndViewhandleHandlerMethodValidationException(HandlerMethodValidationException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) コントローラーメソッドのメソッド検証が失敗した場合を処理します。protected @Nullable ModelAndViewhandleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) クライアントに受け入れられるメッセージコンバーターが見つからなかった場合を処理します(Acceptヘッダーを介して表現されます)。protected @Nullable ModelAndViewhandleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) PUT または POST されたコンテンツのメッセージコンバーターが見つからなかった場合を処理します。protected ModelAndViewhandleHttpMessageNotReadable(HttpMessageNotReadableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) メッセージコンバーターが HTTP リクエストから読み取れない場合に対処します。protected ModelAndViewhandleHttpMessageNotWritable(HttpMessageNotWritableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) メッセージコンバーターが HTTP レスポンスに書き込めない場合に対処します。protected @Nullable ModelAndViewhandleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) HTTP メソッドのハンドラーが見つからない場合を処理します。protected @Nullable ModelAndViewhandleMethodArgumentNotValidException(MethodArgumentNotValidException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) protected ModelAndViewhandleMethodValidationException(MethodValidationException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) たとえば、基盤となるサービスなど、Web コントローラーではないコンポーネントでメソッド検証が失敗した場合を処理します。protected @Nullable ModelAndViewhandleMissingPathVariable(MissingPathVariableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) 宣言されたパス変数が抽出されたどの URI 変数とも一致しない場合のケースを処理します。protected @Nullable ModelAndViewhandleMissingServletRequestParameter(MissingServletRequestParameterException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) 必須パラメーターが欠落している場合に対処します。protected @Nullable ModelAndViewhandleMissingServletRequestPartException(MissingServletRequestPartException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) protected @Nullable ModelAndViewhandleNoHandlerFoundException(NoHandlerFoundException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) ディスパッチ中にハンドラーが見つからなかった場合を処理します。protected @Nullable ModelAndViewhandleNoResourceFoundException(NoResourceFoundException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) 静的リソースが見つからなかった場合に対処します。protected @Nullable ModelAndViewhandleServletRequestBindingException(ServletRequestBindingException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) 回復不可能なバインディング例外が発生した場合 (必要なヘッダー、必要な Cookie など) を処理します。protected ModelAndViewhandleTypeMismatch(TypeMismatchException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) WebDataBinder変換エラーが発生した場合のケースを処理します。protected voidlogException(ExceptionSE ex, jakarta.servlet.http.HttpServletRequest request) "warnLogCategory"プロパティを介して警告ログが有効になっている場合、警告レベルで特定の例外をログに記録します。protected voidsendServerError(ExceptionSE ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) サーバーエラーを送信するために呼び出されました。クラス AbstractHandlerExceptionResolver から継承されたメソッド
addMappedHandlerClass, buildLogMessage, getMappedHandlerClasses, getOrder, hasHandlerMappings, prepareResponse, preventCaching, resolveException, setMappedHandlerClasses, setMappedHandlerPredicate, setMappedHandlers, setOrder, setPreventResponseCaching, setWarnLogCategory, shouldApplyTo
フィールドの詳細
PAGE_NOT_FOUND_LOG_CATEGORY
リクエストに対してマップされたハンドラーが見つからない場合に使用するログカテゴリ。- 関連事項:
pageNotFoundLogger
protected static final org.apache.commons.logging.Log pageNotFoundLoggerリクエストに対してマップされたハンドラーが見つからない場合に使用する追加のロガー。- 関連事項:
コンストラクターの詳細
DefaultHandlerExceptionResolver
public DefaultHandlerExceptionResolver()順序をOrdered.LOWEST_PRECEDENCEに設定します。
メソッドの詳細
doResolveException
protected @Nullable ModelAndView doResolveException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler, ExceptionSE ex) クラスからコピーされた説明:AbstractHandlerExceptionResolverハンドラーの実行中にスローされた特定の例外を実際に解決し、適切であれば特定のエラーページを表すModelAndViewを返します。特定の例外チェックを適用するために、サブクラスでオーバーライドできます。このテンプレートメソッドは、このリゾルバーが適用されるかどうか ( "mappedHandlers" など) を確認した後に呼び出されるため、実装では実際の例外処理をそのまま続行できます。
- 次で指定:
- クラス
AbstractHandlerExceptionResolverのdoResolveException - パラメーター:
request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)ex- ハンドラーの実行中にスローされた例外- 戻り値:
- 転送先の対応する
ModelAndView、または解決チェーンでのデフォルト処理の場合はnull
handleHttpRequestMethodNotSupported
protected @Nullable ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE HTTP メソッドのハンドラーが見つからない場合を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される HttpRequestMethodNotSupportedExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleHttpMediaTypeNotSupported
protected @Nullable ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE PUT または POST されたコンテンツのメッセージコンバーターが見つからなかった場合を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される HttpMediaTypeNotSupportedExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleHttpMediaTypeNotAcceptable
protected @Nullable ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE クライアントに受け入れられるメッセージコンバーターが見つからなかった場合を処理します(Acceptヘッダーを介して表現されます)。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される HttpMediaTypeNotAcceptableExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleMissingPathVariable
protected @Nullable ModelAndView handleMissingPathVariable(MissingPathVariableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE 宣言されたパス変数が抽出されたどの URI 変数とも一致しない場合のケースを処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される MissingPathVariableExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 4.2
handleMissingServletRequestParameter
protected @Nullable ModelAndView handleMissingServletRequestParameter(MissingServletRequestParameterException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE 必須パラメーターが欠落している場合に対処します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される MissingServletRequestParameterExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleMissingServletRequestPartException
protected @Nullable ModelAndView handleMissingServletRequestPartException(MissingServletRequestPartException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE @RequestPart、MultipartFile、jakarta.servlet.http.Part引数が必要であるが欠落しているケースを処理します。デフォルトでは、HTTP 400 エラーがクライアントに送り返されます。
- パラメーター:
request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleServletRequestBindingException
protected @Nullable ModelAndView handleServletRequestBindingException(ServletRequestBindingException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE 回復不可能なバインディング例外が発生した場合 (必要なヘッダー、必要な Cookie など) を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される例外request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleMethodArgumentNotValidException
protected @Nullable ModelAndView handleMethodArgumentNotValidException(MethodArgumentNotValidException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE RequestBodyまたはRequestPart引数など、@Validでアノテーションが付けられた引数が検証に失敗した場合の処理。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleHandlerMethodValidationException
protected @Nullable ModelAndView handleHandlerMethodValidationException(HandlerMethodValidationException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE コントローラーメソッドのメソッド検証が失敗した場合を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される例外request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 6.1
handleNoHandlerFoundException
protected @Nullable ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE ディスパッチ中にハンドラーが見つからなかった場合を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理される NoHandlerFoundExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 4.0
handleNoResourceFoundException
protected @Nullable ModelAndView handleNoResourceFoundException(NoResourceFoundException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE 静的リソースが見つからなかった場合に対処します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理されるNoResourceFoundExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- リソースハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 6.1
handleAsyncRequestTimeoutException
protected @Nullable ModelAndView handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE 非同期リクエストがタイムアウトした場合を処理します。デフォルトの実装は
nullを返します。この場合、例外はhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で処理されます。- パラメーター:
ex- 処理されるAsyncRequestTimeoutExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView、またはhandleErrorResponse(ErrorResponse, HttpServletRequest, HttpServletResponse, Object)で例外を処理する必要があることを示すnull - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 4.2.8
handleAsyncRequestNotUsableException
protected ModelAndView handleAsyncRequestNotUsableException(AsyncRequestNotUsableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) ServletOutputStream からの I/O 障害の場合に対処します。デフォルトでは、レスポンスは使用できないため、何もしません。
- パラメーター:
ex- 処理されるAsyncRequestTimeoutExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)- 戻り値:
- 例外が処理されたことを示す空の ModelAndView
- 導入:
- 5.3.33
handleDisconnectedClientException
protected ModelAndView handleDisconnectedClientException(ExceptionSE ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) クライアントが去ったことを示す例外を処理します。これは通常、特定のサブ型のIOExceptionSE または基礎となるサーブレットコンテナーに固有のメッセージです。これらはDisconnectedClientHelper.isClientDisconnectedException(Throwable)を通じて検出されます。デフォルトでは、レスポンスは使用できないため、何もしません。
- パラメーター:
ex- 処理されるExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー、または例外時に何も選択されなかった場合はnull(たとえば、マルチパート解決が失敗した場合)- 戻り値:
- 例外が処理されたことを示す空の ModelAndView
- 導入:
- 6.2
handleErrorResponse
protected ModelAndView handleErrorResponse(ErrorResponse errorResponse, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE ErrorResponse例外を処理します。デフォルトの実装では、ステータスとレスポンスのヘッダーは
ErrorResponseから取得したものになります。ProblemDetail.getDetail()が利用可能な場合は、それがHttpServletResponse.sendError(int, String)のメッセージとして使用されます。- パラメーター:
errorResponse- 処理される例外request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 6.0
handleConversionNotSupported
protected ModelAndView handleConversionNotSupported(ConversionNotSupportedException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE WebDataBinder変換が発生しないケースを処理します。デフォルトの実装は HTTP 500 エラーを送信し、空の
ModelAndViewを返します。または、フォールバックビューを選択するか、ConversionNotSupportedException をそのまま再スローできます。- パラメーター:
ex- 処理される ConversionNotSupportedExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleTypeMismatch
protected ModelAndView handleTypeMismatch(TypeMismatchException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE WebDataBinder変換エラーが発生した場合のケースを処理します。デフォルトの実装は HTTP 400 エラーを送信し、空の
ModelAndViewを返します。または、フォールバックビューを選択するか、TypeMismatchException をそのまま再スローできます。- パラメーター:
ex- 処理される TypeMismatchExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleHttpMessageNotReadable
protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE メッセージコンバーターが HTTP リクエストから読み取れない場合に対処します。デフォルトの実装は HTTP 400 エラーを送信し、空の
ModelAndViewを返します。または、フォールバックビューを選択するか、HttpMessageNotReadableException をそのまま再スローできます。- パラメーター:
ex- 処理される HttpMessageNotReadableExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleHttpMessageNotWritable
protected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE メッセージコンバーターが HTTP レスポンスに書き込めない場合に対処します。デフォルトの実装は HTTP 500 エラーを送信し、空の
ModelAndViewを返します。または、フォールバックビューを選択するか、HttpMessageNotWritableException をそのまま再スローできます。- パラメーター:
ex- 処理される HttpMessageNotWritableExceptionrequest- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある
handleMethodValidationException
protected ModelAndView handleMethodValidationException(MethodValidationException ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, @Nullable ObjectSE handler) throws IOExceptionSE たとえば、基盤となるサービスなど、Web コントローラーではないコンポーネントでメソッド検証が失敗した場合を処理します。デフォルトの実装は HTTP 500 エラーを送信し、空の
ModelAndViewを返します。または、フォールバックビューを選択するか、HttpMessageNotWritableException をそのまま再スローできます。- パラメーター:
ex- 処理される例外request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンスhandler- 実行されたハンドラー- 戻り値:
- 例外が処理されたことを示す空の
ModelAndView - 例外:
IOExceptionSE-HttpServletResponse.sendError(int, String)から投げられる可能性がある- 導入:
- 6.1
sendServerError
protected void sendServerError(ExceptionSE ex, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOExceptionSE サーバーエラーを送信するために呼び出されます。ステータスを 500 に設定し、リクエスト属性 "jakarta.servlet.error.exception" を例外に設定します。logException
クラスからコピーされた説明:AbstractHandlerExceptionResolver"warnLogCategory"プロパティを介して警告ログが有効になっている場合、警告レベルで特定の例外をログに記録します。ログに記録する具体的なメッセージを判別するために、
AbstractHandlerExceptionResolver.buildLogMessage(Exception, HttpServletRequest)を呼び出します。- オーバーライド:
- クラス
AbstractHandlerExceptionResolverのlogException - パラメーター:
ex- ハンドラーの実行中にスローされた例外request- 現在の HTTP リクエスト (メタデータの取得に役立ちます)- 関連事項: