1 /* 2 * Copyright 2002-2005 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.web.servlet; 18 19 import javax.servlet.http.HttpServletRequest; 20 import javax.servlet.http.HttpServletResponse; 21 22 /** 23 * Interface to be implemented by objects than can resolve exceptions thrown 24 * during handler mapping or execution, in the typical case to error views. 25 * Implementors are typically registered as beans in the application context. 26 * 27 * <p>Error views are analogous to the error page JSPs, but can be used with 28 * any kind of exception including any checked exception, with potentially 29 * fine-granular mappings for specific handlers. 30 * 31 * @author Juergen Hoeller 32 * @since 22.11.2003 33 */ 34 public interface HandlerExceptionResolver { 35 36 /** 37 * Try to resolve the given exception that got thrown during on handler execution, 38 * returning a ModelAndView that represents a specific error page if appropriate. 39 * @param request current HTTP request 40 * @param response current HTTP response 41 * @param handler the executed handler, or <code>null</code> if none chosen at the time of 42 * the exception (for example, if multipart resolution failed) 43 * @param ex the exception that got thrown during handler execution 44 * @return a corresponding ModelAndView to forward to, or <code>null</code> for default processing 45 */ 46 ModelAndView resolveException( 47 HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex); 48 49 } 50