/** * Return a ModelAndView for the given request, view name and exception. * <p>The default implementation delegates to {@link #getModelAndView(String, Exception)}. * @param viewName the name of the error view * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @return the ModelAndView instance */ protected ModelAndView getModelAndView(String viewName, Exception ex, HttpServletRequest request) { return getModelAndView(viewName, ex); }
/** * Return a ModelAndView for the given request, view name and exception. * <p>The default implementation delegates to {@link #getModelAndView(String, Exception)}. * @param viewName the name of the error view * @param ex the exception that got thrown during handler execution * @param request current HTTP request (useful for obtaining metadata) * @return the ModelAndView instance */ protected ModelAndView getModelAndView(String viewName, Exception ex, HttpServletRequest request) { return getModelAndView(viewName, ex); }
applyStatusCodeIfPossible(request, response, statusCode); return getModelAndView(viewName, ex, request);
applyStatusCodeIfPossible(request, response, statusCode); return getModelAndView(viewName, ex, request);
@Override protected ModelAndView getModelAndView(String viewName, Exception ex) { log.error("Unhandled exception", ex); ModelAndView mv = super.getModelAndView(viewName, ex); Throwable rootCause = ex; while (rootCause.getCause() != null) { rootCause = rootCause.getCause(); } mv.getModel().put(rootCaseAttribute, rootCause); return mv; }
/** {@inheritDoc} */ @Override protected ModelAndView getModelAndView(final String viewName, final Exception ex, final HttpServletRequest request) { LoggerFactory.getLogger(ex.getClass()).error("", ex); final ModelAndView view = super.getModelAndView(viewName, ex, request); view.addObject(MODEL_ATTR_REQUEST, request); view.addObject(MODEL_ATTR_ENCODER, HTMLEncoder.class); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); if (context != null) { view.addObject(MODEL_ATTR_SPRINGCONTEXT, context); } if (viewModelExtenderFunction != null) { final Map<String,Object> exts = viewModelExtenderFunction.apply(request); if (exts != null) { view.addAllObjects(exts); } } return view; }
return getModelAndView(viewName, ex);
applyStatusCodeIfPossible(request, response, statusCode); return getModelAndView(viewName, ex, request);