Browse Source

DispatcherServlet applies view name translation to error views as well (SPR-7298)

pull/1234/head
Juergen Hoeller 15 years ago
parent
commit
d49c067770
  1. 15
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

15
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

@ -996,12 +996,10 @@ public class DispatcherServlet extends FrameworkServlet { @@ -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 { @@ -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;

Loading…
Cancel
Save