0
私はspring mvcベースのプロジェクトで働いており、DefaultHandlerExceptionResolver
を拡張して例外タイプに応じてエラーページにリダイレクトすることによってExceptionResolver
を開発しました。ファサード、サービス、DAOレイヤーで発生した例外のために働いています。Spring MVCで例外を処理する方法は?
しかし、サーブレットフィルタで発生した例外に対しては機能しません。それには何が必要ですか?
以下は私のhandlerExceptionResolver
public ModelAndView doResolveException(final HttpServletRequest request, final HttpServletResponse response, final Object obj,
final Exception exception){
ModelAndView modelAndView = super.doResolveException(request, response, obj, exception);
modelAndView = Objects.nonNull(modelAndView) ? modelAndView : new ModelAndView();
final String url = Config.getParameter(EXCEPTION_HANDLER_URL);
modelAndView.setViewName(url);
final FlashMap outputFlashMap = RequestContextUtils.getOutputFlashMap(request);
outputFlashMap.put(ERROR_DETAILS, exception);
if (exception instanceof BusinessExecutionException)
{
return handleBusinessExecutionExceptionMethod((BusinessExecutionException) exception, outputFlashMap, modelAndView);
}
else if (exception instanceof IntegrationExecutionException)
{
return handleIntegrationExecutionExceptionMethod((IntegrationExecutionException) exception, outputFlashMap,
modelAndView);
}
else if (exception instanceof DataAccessObjectExecutionException)
{
return handleDAOExecutionExceptionMethod((DataAccessObjectExecutionException) exception, outputFlashMap, modelAndView);
}
return handleMiscException(exception, outputFlashMap, modelAndView);
}
あなたが今持っているものを提供していない場合、どのような変更が必要かを教えてもらえませんでした。 – ChiefTwoPencils
このhttp://www.journaldev.com/2676/spring-mvc-interceptors-example-handlerインターセプタ - と - ハンドラインタセプタのアダプタをご覧ください。 –