2016-04-05 26 views
0

Yay mvc tabanlı bir projede çalışıyorum ve istisna tipine bağlı olarak hata sayfasına yeniden yönlendirmek için DefaultHandlerExceptionResolver genişleterek ExceptionResolver geliştirdiler. Cephe, servis, DAO katmanında kaldırılan istisna için çalışıyor.Bahar MVC'deki istisnalar nasıl ele alınır?

Ancak, Servlet filtresinde yükseltilen istisnalar için çalışmaz. Bunun için hangi değişiklikler yapılmalı?

Aşağıda benim 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); 

} 
+1

Şimdi sahip olduğunuz şeyi sağlamadığınız takdirde hangi değişikliklerin yapılması gerektiğini size söyleyemedik. – ChiefTwoPencils

+1

Bu http://www.journaldev.com/2676/spring-mvc-interceptors-example-handlerinterceptor-and-handlerinterceptoradapter sayfasına bir göz atın. –

cevap

İlgili konular