1. private void processDispatchResult(HttpServletRequest request, HttpServletResponse response, @Nullable HandlerExecutionChain mappedHandler, @Nullable ModelAndView mv, @Nullable Exception exception) throws Exception {
    2. boolean errorView = false;
    3. if (exception != null) {
    4. if (exception instanceof ModelAndViewDefiningException) {
    5. this.logger.debug("ModelAndViewDefiningException encountered", exception);
    6. mv = ((ModelAndViewDefiningException)exception).getModelAndView();
    7. } else {
    8. Object handler = mappedHandler != null ? mappedHandler.getHandler() : null;
    9. mv = this.processHandlerException(request, response, handler, exception);
    10. errorView = mv != null;
    11. }
    12. }
    13. if (mv != null && !mv.wasCleared()) {
    14. this.render(mv, request, response);
    15. if (errorView) {
    16. WebUtils.clearErrorRequestAttributes(request);
    17. }
    18. } else if (this.logger.isTraceEnabled()) {
    19. this.logger.trace("No view rendering, null ModelAndView returned.");
    20. }
    21. if (!WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
    22. if (mappedHandler != null) {
    23. mappedHandler.triggerAfterCompletion(request, response, (Exception)null);
    24. }
    25. }
    26. }