对于异常我们可以通过注册一个实现HandlerExceptionResolver
接口的Bean来解决
@Component
public class CustomerHandlerException implements HandlerExceptionResolver {
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
System.err.println(handler.getClass()+" "+request.getRequestURI()+" "+ex.getMessage());
return null;
}
}