From d49c067770241f6287abc94f9fb08d22b1966fca Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 20 Jun 2010 19:06:56 +0000 Subject: [PATCH] DispatcherServlet applies view name translation to error views as well (SPR-7298) --- .../web/servlet/DispatcherServlet.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index c1388404cd..a49eb92b87 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -996,12 +996,10 @@ public class DispatcherServlet extends FrameworkServlet { * @return a corresponding ModelAndView to forward to * @throws Exception if no error ModelAndView found */ - protected ModelAndView processHandlerException(HttpServletRequest request, - HttpServletResponse response, - Object handler, - Exception ex) throws Exception { + protected ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception ex) throws Exception { - // Check registerer HandlerExceptionResolvers... + // Check registered HandlerExceptionResolvers... ModelAndView exMv = null; for (HandlerExceptionResolver handlerExceptionResolver : this.handlerExceptionResolvers) { exMv = handlerExceptionResolver.resolveException(request, response, handler, ex); @@ -1013,9 +1011,12 @@ public class DispatcherServlet extends FrameworkServlet { if (exMv.isEmpty()) { return null; } + // We might still need view name translation for a plain error model... + if (!exMv.hasView()) { + exMv.setViewName(getDefaultViewName(request)); + } if (logger.isDebugEnabled()) { - logger.debug("Handler execution resulted in exception - forwarding to resolved error view: " + exMv, - ex); + logger.debug("Handler execution resulted in exception - forwarding to resolved error view: " + exMv, ex); } WebUtils.exposeErrorRequestAttributes(request, ex, getServletName()); return exMv;