polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -44,7 +44,8 @@ public interface HandlerExceptionResolver {
|
|||||||
* @param handler the executed handler, or null if none chosen at the time of
|
* @param handler the executed handler, or null if none chosen at the time of
|
||||||
* the exception (for example, if multipart resolution failed)
|
* the exception (for example, if multipart resolution failed)
|
||||||
* @param ex the exception that got thrown during handler execution
|
* @param ex the exception that got thrown during handler execution
|
||||||
* @return a corresponding ModelAndView to forward to, or null for default processing
|
* @return a corresponding ModelAndView to forward to,
|
||||||
|
* or <code>null</code> for default processing
|
||||||
*/
|
*/
|
||||||
ModelAndView resolveException(
|
ModelAndView resolveException(
|
||||||
RenderRequest request, RenderResponse response, Object handler, Exception ex);
|
RenderRequest request, RenderResponse response, Object handler, Exception ex);
|
||||||
@@ -57,7 +58,8 @@ public interface HandlerExceptionResolver {
|
|||||||
* @param handler the executed handler, or null if none chosen at the time of
|
* @param handler the executed handler, or null if none chosen at the time of
|
||||||
* the exception (for example, if multipart resolution failed)
|
* the exception (for example, if multipart resolution failed)
|
||||||
* @param ex the exception that got thrown during handler execution
|
* @param ex the exception that got thrown during handler execution
|
||||||
* @return a corresponding ModelAndView to forward to, or null for default processing
|
* @return a corresponding ModelAndView to forward to,
|
||||||
|
* or <code>null</code> for default processing
|
||||||
*/
|
*/
|
||||||
ModelAndView resolveException(
|
ModelAndView resolveException(
|
||||||
ResourceRequest request, ResourceResponse response, Object handler, Exception ex);
|
ResourceRequest request, ResourceResponse response, Object handler, Exception ex);
|
||||||
|
|||||||
@@ -137,39 +137,41 @@ public class DispatcherServlet extends FrameworkServlet {
|
|||||||
public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver";
|
public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Well-known name for the HandlerMapping object in the bean factory for this namespace. Only used when
|
* Well-known name for the HandlerMapping object in the bean factory for this namespace.
|
||||||
* "detectAllHandlerMappings" is turned off.
|
* Only used when "detectAllHandlerMappings" is turned off.
|
||||||
* @see #setDetectAllHandlerMappings
|
* @see #setDetectAllHandlerMappings
|
||||||
*/
|
*/
|
||||||
public static final String HANDLER_MAPPING_BEAN_NAME = "handlerMapping";
|
public static final String HANDLER_MAPPING_BEAN_NAME = "handlerMapping";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Well-known name for the HandlerAdapter object in the bean factory for this namespace. Only used when
|
* Well-known name for the HandlerAdapter object in the bean factory for this namespace.
|
||||||
* "detectAllHandlerAdapters" is turned off.
|
* Only used when "detectAllHandlerAdapters" is turned off.
|
||||||
* @see #setDetectAllHandlerAdapters
|
* @see #setDetectAllHandlerAdapters
|
||||||
*/
|
*/
|
||||||
public static final String HANDLER_ADAPTER_BEAN_NAME = "handlerAdapter";
|
public static final String HANDLER_ADAPTER_BEAN_NAME = "handlerAdapter";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace. Only used when
|
* Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace.
|
||||||
* "detectAllHandlerExceptionResolvers" is turned off.
|
* Only used when "detectAllHandlerExceptionResolvers" is turned off.
|
||||||
* @see #setDetectAllHandlerExceptionResolvers
|
* @see #setDetectAllHandlerExceptionResolvers
|
||||||
*/
|
*/
|
||||||
public static final String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME = "handlerExceptionResolver";
|
public static final String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME = "handlerExceptionResolver";
|
||||||
|
|
||||||
/** Well-known name for the RequestToViewNameTranslator object in the bean factory for this namespace. */
|
/**
|
||||||
|
* Well-known name for the RequestToViewNameTranslator object in the bean factory for this namespace.
|
||||||
|
*/
|
||||||
public static final String REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME = "viewNameTranslator";
|
public static final String REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME = "viewNameTranslator";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Well-known name for the ViewResolver object in the bean factory for this namespace. Only used when
|
* Well-known name for the ViewResolver object in the bean factory for this namespace.
|
||||||
* "detectAllViewResolvers" is turned off.
|
* Only used when "detectAllViewResolvers" is turned off.
|
||||||
* @see #setDetectAllViewResolvers
|
* @see #setDetectAllViewResolvers
|
||||||
*/
|
*/
|
||||||
public static final String VIEW_RESOLVER_BEAN_NAME = "viewResolver";
|
public static final String VIEW_RESOLVER_BEAN_NAME = "viewResolver";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request attribute to hold the current web application context. Otherwise only the global web app context is
|
* Request attribute to hold the current web application context.
|
||||||
* obtainable by tags etc.
|
* Otherwise only the global web app context is obtainable by tags etc.
|
||||||
* @see org.springframework.web.servlet.support.RequestContextUtils#getWebApplicationContext
|
* @see org.springframework.web.servlet.support.RequestContextUtils#getWebApplicationContext
|
||||||
*/
|
*/
|
||||||
public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE = DispatcherServlet.class.getName() + ".CONTEXT";
|
public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE = DispatcherServlet.class.getName() + ".CONTEXT";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,14 +36,16 @@ public interface HandlerExceptionResolver {
|
|||||||
/**
|
/**
|
||||||
* Try to resolve the given exception that got thrown during on handler execution,
|
* Try to resolve the given exception that got thrown during on handler execution,
|
||||||
* returning a ModelAndView that represents a specific error page if appropriate.
|
* returning a ModelAndView that represents a specific error page if appropriate.
|
||||||
* <p>The returned ModelAndView may be {@linkplain ModelAndView#isEmpty() empty} to indicate that the exception has
|
* <p>The returned ModelAndView may be {@linkplain ModelAndView#isEmpty() empty}
|
||||||
* been resolved successfully, but that no view should be rendered, for instance by setting a status code.
|
* to indicate that the exception has been resolved successfully but that no view
|
||||||
|
* should be rendered, for instance by setting a status code.
|
||||||
* @param request current HTTP request
|
* @param request current HTTP request
|
||||||
* @param response current HTTP response
|
* @param response current HTTP response
|
||||||
* @param handler the executed handler, or <code>null</code> if none chosen at the
|
* @param handler the executed handler, or <code>null</code> if none chosen at the
|
||||||
* time of the exception (for example, if multipart resolution failed)
|
* time of the exception (for example, if multipart resolution failed)
|
||||||
* @param ex the exception that got thrown during handler execution
|
* @param ex the exception that got thrown during handler execution
|
||||||
* @return a corresponding ModelAndView to forward to, or <code>null</code> for default processing
|
* @return a corresponding ModelAndView to forward to,
|
||||||
|
* or <code>null</code> for default processing
|
||||||
*/
|
*/
|
||||||
ModelAndView resolveException(
|
ModelAndView resolveException(
|
||||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex);
|
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ import org.springframework.core.MethodParameter;
|
|||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.http.HttpInputMessage;
|
import org.springframework.http.HttpInputMessage;
|
||||||
import org.springframework.http.HttpOutputMessage;
|
import org.springframework.http.HttpOutputMessage;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
@@ -400,9 +400,9 @@ public class AnnotationMethodHandlerExceptionResolver extends AbstractHandlerExc
|
|||||||
MediaType.sortByQualityValue(acceptedMediaTypes);
|
MediaType.sortByQualityValue(acceptedMediaTypes);
|
||||||
HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
|
HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
|
||||||
Class<?> returnValueType = returnValue.getClass();
|
Class<?> returnValueType = returnValue.getClass();
|
||||||
if (messageConverters != null) {
|
if (this.messageConverters != null) {
|
||||||
for (MediaType acceptedMediaType : acceptedMediaTypes) {
|
for (MediaType acceptedMediaType : acceptedMediaTypes) {
|
||||||
for (HttpMessageConverter messageConverter : messageConverters) {
|
for (HttpMessageConverter messageConverter : this.messageConverters) {
|
||||||
if (messageConverter.canWrite(returnValueType, acceptedMediaType)) {
|
if (messageConverter.canWrite(returnValueType, acceptedMediaType)) {
|
||||||
messageConverter.write(returnValue, acceptedMediaType, outputMessage);
|
messageConverter.write(returnValue, acceptedMediaType, outputMessage);
|
||||||
return new ModelAndView();
|
return new ModelAndView();
|
||||||
|
|||||||
Reference in New Issue
Block a user