mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-09 00:29:04 +00:00
Polishing (in particular updating javadoc references to Apache Commons)
(cherry picked from commit bc6a98c)
This commit is contained in:
+66
-50
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,73 +60,89 @@ import org.springframework.web.util.NestedServletException;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Central dispatcher for HTTP request handlers/controllers, e.g. for web UI controllers or HTTP-based remote service
|
||||
* exporters. Dispatches to registered handlers for processing a web request, providing convenient mapping and exception
|
||||
* handling facilities.
|
||||
* Central dispatcher for HTTP request handlers/controllers, e.g. for web UI controllers
|
||||
* or HTTP-based remote service exporters. Dispatches to registered handlers for processing
|
||||
* a web request, providing convenient mapping and exception handling facilities.
|
||||
*
|
||||
* <p>This servlet is very flexible: It can be used with just about any workflow, with the installation of the
|
||||
* appropriate adapter classes. It offers the following functionality that distinguishes it from other request-driven
|
||||
* web MVC frameworks:
|
||||
* <p>This servlet is very flexible: It can be used with just about any workflow, with the
|
||||
* installation of the appropriate adapter classes. It offers the following functionality
|
||||
* that distinguishes it from other request-driven web MVC frameworks:
|
||||
*
|
||||
* <ul> <li>It is based around a JavaBeans configuration mechanism.
|
||||
* <ul>
|
||||
* <li>It is based around a JavaBeans configuration mechanism.
|
||||
*
|
||||
* <li>It can use any {@link HandlerMapping} implementation - pre-built or provided as part of an application - to
|
||||
* control the routing of requests to handler objects. Default is {@link org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping}
|
||||
* and {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}. HandlerMapping objects
|
||||
* can be defined as beans in the servlet's application context, implementing the HandlerMapping interface, overriding
|
||||
* the default HandlerMapping if present. HandlerMappings can be given any bean name (they are tested by type).
|
||||
* <li>It can use any {@link HandlerMapping} implementation - pre-built or provided as part
|
||||
* of an application - to control the routing of requests to handler objects. Default is
|
||||
* {@link org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping} and
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping}.
|
||||
* HandlerMapping objects can be defined as beans in the servlet's application context,
|
||||
* implementing the HandlerMapping interface, overriding the default HandlerMapping if
|
||||
* present. HandlerMappings can be given any bean name (they are tested by type).
|
||||
*
|
||||
* <li>It can use any {@link HandlerAdapter}; this allows for using any handler interface. Default adapters are {@link
|
||||
* org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter}, {@link org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter},
|
||||
* for Spring's {@link org.springframework.web.HttpRequestHandler} and {@link org.springframework.web.servlet.mvc.Controller}
|
||||
* interfaces, respectively. A default {@link org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter}
|
||||
* will be registered as well. HandlerAdapter objects can be added as beans in the application context, overriding the
|
||||
* default HandlerAdapters. Like HandlerMappings, HandlerAdapters can be given any bean name (they are tested by type).
|
||||
* <li>It can use any {@link HandlerAdapter}; this allows for using any handler interface.
|
||||
* Default adapters are {@link org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter},
|
||||
* {@link org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter}, for Spring's
|
||||
* {@link org.springframework.web.HttpRequestHandler} and
|
||||
* {@link org.springframework.web.servlet.mvc.Controller} interfaces, respectively. A default
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter}
|
||||
* will be registered as well. HandlerAdapter objects can be added as beans in the
|
||||
* application context, overriding the default HandlerAdapters. Like HandlerMappings,
|
||||
* HandlerAdapters can be given any bean name (they are tested by type).
|
||||
*
|
||||
* <li>The dispatcher's exception resolution strategy can be specified via a {@link HandlerExceptionResolver}, for
|
||||
* example mapping certain exceptions to error pages. Default are
|
||||
* <li>The dispatcher's exception resolution strategy can be specified via a
|
||||
* {@link HandlerExceptionResolver}, for example mapping certain exceptions to error pages.
|
||||
* Default are
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver},
|
||||
* {@link org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver}, and
|
||||
* {@link org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver}. These HandlerExceptionResolvers can be overridden
|
||||
* through the application context. HandlerExceptionResolver can be given any bean name (they are tested by type).
|
||||
* {@link org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver}.
|
||||
* These HandlerExceptionResolvers can be overridden through the application context.
|
||||
* HandlerExceptionResolver can be given any bean name (they are tested by type).
|
||||
*
|
||||
* <li>Its view resolution strategy can be specified via a {@link ViewResolver} implementation, resolving symbolic view
|
||||
* names into View objects. Default is {@link org.springframework.web.servlet.view.InternalResourceViewResolver}.
|
||||
* ViewResolver objects can be added as beans in the application context, overriding the default ViewResolver.
|
||||
* ViewResolvers can be given any bean name (they are tested by type).
|
||||
* <li>Its view resolution strategy can be specified via a {@link ViewResolver}
|
||||
* implementation, resolving symbolic view names into View objects. Default is
|
||||
* {@link org.springframework.web.servlet.view.InternalResourceViewResolver}.
|
||||
* ViewResolver objects can be added as beans in the application context, overriding the
|
||||
* default ViewResolver. ViewResolvers can be given any bean name (they are tested by type).
|
||||
*
|
||||
* <li>If a {@link View} or view name is not supplied by the user, then the configured {@link
|
||||
* RequestToViewNameTranslator} will translate the current request into a view name. The corresponding bean name is
|
||||
* "viewNameTranslator"; the default is {@link org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator}.
|
||||
* <li>If a {@link View} or view name is not supplied by the user, then the configured
|
||||
* {@link RequestToViewNameTranslator} will translate the current request into a view name.
|
||||
* The corresponding bean name is "viewNameTranslator"; the default is
|
||||
* {@link org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator}.
|
||||
*
|
||||
* <li>The dispatcher's strategy for resolving multipart requests is determined by a {@link
|
||||
* org.springframework.web.multipart.MultipartResolver} implementation. Implementations for Jakarta Commons FileUpload
|
||||
* and Jason Hunter's COS are included; the typical choise is {@link org.springframework.web.multipart.commons.CommonsMultipartResolver}.
|
||||
* <li>The dispatcher's strategy for resolving multipart requests is determined by a
|
||||
* {@link org.springframework.web.multipart.MultipartResolver} implementation.
|
||||
* Implementations for Apache Commons FileUpload and Servlet 3 are included; the typical
|
||||
* choice is {@link org.springframework.web.multipart.commons.CommonsMultipartResolver}.
|
||||
* The MultipartResolver bean name is "multipartResolver"; default is none.
|
||||
*
|
||||
* <li>Its locale resolution strategy is determined by a {@link LocaleResolver}. Out-of-the-box implementations work via
|
||||
* HTTP accept header, cookie, or session. The LocaleResolver bean name is "localeResolver"; default is {@link
|
||||
* org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver}.
|
||||
* <li>Its locale resolution strategy is determined by a {@link LocaleResolver}.
|
||||
* Out-of-the-box implementations work via HTTP accept header, cookie, or session.
|
||||
* The LocaleResolver bean name is "localeResolver"; default is
|
||||
* {@link org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver}.
|
||||
*
|
||||
* <li>Its theme resolution strategy is determined by a {@link ThemeResolver}. Implementations for a fixed theme and for
|
||||
* cookie and session storage are included. The ThemeResolver bean name is "themeResolver"; default is {@link
|
||||
* org.springframework.web.servlet.theme.FixedThemeResolver}. </ul>
|
||||
* <li>Its theme resolution strategy is determined by a {@link ThemeResolver}.
|
||||
* Implementations for a fixed theme and for cookie and session storage are included.
|
||||
* The ThemeResolver bean name is "themeResolver"; default is
|
||||
* {@link org.springframework.web.servlet.theme.FixedThemeResolver}.
|
||||
* </ul>
|
||||
*
|
||||
* <p><b>NOTE: The {@code @RequestMapping} annotation will only be processed if a corresponding
|
||||
* {@code HandlerMapping} (for type level annotations) and/or {@code HandlerAdapter} (for method level
|
||||
* annotations) is present in the dispatcher.</b> This is the case by default. However, if you are defining custom
|
||||
* {@code HandlerMappings} or {@code HandlerAdapters}, then you need to make sure that a corresponding custom
|
||||
* {@code DefaultAnnotationHandlerMapping} and/or {@code AnnotationMethodHandlerAdapter} is defined as well -
|
||||
* provided that you intend to use {@code @RequestMapping}.
|
||||
* <p><b>NOTE: The {@code @RequestMapping} annotation will only be processed if a
|
||||
* corresponding {@code HandlerMapping} (for type-level annotations) and/or
|
||||
* {@code HandlerAdapter} (for method-level annotations) is present in the dispatcher.</b>
|
||||
* This is the case by default. However, if you are defining custom {@code HandlerMappings}
|
||||
* or {@code HandlerAdapters}, then you need to make sure that a corresponding custom
|
||||
* {@code DefaultAnnotationHandlerMapping} and/or {@code AnnotationMethodHandlerAdapter}
|
||||
* is defined as well - provided that you intend to use {@code @RequestMapping}.
|
||||
*
|
||||
* <p><b>A web application can define any number of DispatcherServlets.</b> Each servlet will operate in its own
|
||||
* namespace, loading its own application context with mappings, handlers, etc. Only the root application context as
|
||||
* loaded by {@link org.springframework.web.context.ContextLoaderListener}, if any, will be shared.
|
||||
* <p><b>A web application can define any number of DispatcherServlets.</b>
|
||||
* Each servlet will operate in its own namespace, loading its own application context
|
||||
* with mappings, handlers, etc. Only the root application context as loaded by
|
||||
* {@link org.springframework.web.context.ContextLoaderListener}, if any, will be shared.
|
||||
*
|
||||
* <p>As of Spring 3.1, {@code DispatcherServlet} may now be injected with a web
|
||||
* application context, rather than creating its own internally. This is useful in Servlet
|
||||
* 3.0+ environments, which support programmatic registration of servlet instances. See
|
||||
* {@link #DispatcherServlet(WebApplicationContext)} Javadoc for details.
|
||||
* 3.0+ environments, which support programmatic registration of servlet instances.
|
||||
* See the {@link #DispatcherServlet(WebApplicationContext)} javadoc for details.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -258,7 +258,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
}
|
||||
|
||||
List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
|
||||
Collections.sort(adviceBeans, new OrderComparator());
|
||||
OrderComparator.sort(adviceBeans);
|
||||
|
||||
for (ControllerAdviceBean adviceBean : adviceBeans) {
|
||||
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -519,7 +518,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
||||
}
|
||||
|
||||
List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
|
||||
Collections.sort(beans, new OrderComparator());
|
||||
OrderComparator.sort(beans);
|
||||
|
||||
List<Object> responseBodyAdviceBeans = new ArrayList<Object>();
|
||||
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
|
||||
Map<String, SimpleUrlHandlerMapping> map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
List<SimpleUrlHandlerMapping> handlerMappings = new ArrayList<SimpleUrlHandlerMapping>(map.values());
|
||||
Collections.sort(handlerMappings, new OrderComparator());
|
||||
OrderComparator.sort(handlerMappings);
|
||||
|
||||
for (SimpleUrlHandlerMapping hm : handlerMappings) {
|
||||
for (String pattern : hm.getHandlerMap().keySet()) {
|
||||
|
||||
+22
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,29 +55,31 @@ import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ViewResolver} that resolves a view based on the request file name or {@code Accept} header.
|
||||
* Implementation of {@link ViewResolver} that resolves a view based on the request file name
|
||||
* or {@code Accept} header.
|
||||
*
|
||||
* <p>The {@code ContentNegotiatingViewResolver} does not resolve views itself, but delegates to other {@link
|
||||
* ViewResolver}s. By default, these other view resolvers are picked up automatically from the application context,
|
||||
* though they can also be set explicitly by using the {@link #setViewResolvers(List) viewResolvers} property.
|
||||
* <strong>Note</strong> that in order for this view resolver to work properly, the {@link #setOrder(int) order}
|
||||
* property needs to be set to a higher precedence than the others (the default is {@link Ordered#HIGHEST_PRECEDENCE}.)
|
||||
* <p>The {@code ContentNegotiatingViewResolver} does not resolve views itself, but delegates to
|
||||
* other {@link ViewResolver}s. By default, these other view resolvers are picked up automatically
|
||||
* from the application context, though they can also be set explicitly by using the
|
||||
* {@link #setViewResolvers viewResolvers} property. <strong>Note</strong> that in order for this
|
||||
* view resolver to work properly, the {@link #setOrder order} property needs to be set to a higher
|
||||
* precedence than the others (the default is {@link Ordered#HIGHEST_PRECEDENCE}).
|
||||
*
|
||||
* <p>This view resolver uses the requested {@linkplain MediaType media type} to select a suitable {@link View} for a
|
||||
* request. The requested media type is determined through the configured {@link ContentNegotiationManager}.
|
||||
* Once the requested media type has been determined, this resolver queries each delegate view resolver for a
|
||||
* {@link View} and determines if the requested media type is {@linkplain MediaType#includes(MediaType) compatible}
|
||||
* with the view's {@linkplain View#getContentType() content type}). The most compatible view is returned.
|
||||
* <p>This view resolver uses the requested {@linkplain MediaType media type} to select a suitable
|
||||
* {@link View} for a request. The requested media type is determined through the configured
|
||||
* {@link ContentNegotiationManager}. Once the requested media type has been determined, this resolver
|
||||
* queries each delegate view resolver for a {@link View} and determines if the requested media type
|
||||
* is {@linkplain MediaType#includes(MediaType) compatible} with the view's
|
||||
* {@linkplain View#getContentType() content type}). The most compatible view is returned.
|
||||
*
|
||||
* <p>Additionally, this view resolver exposes the {@link #setDefaultViews(List) defaultViews} property, allowing you to
|
||||
* override the views provided by the view resolvers. Note that these default views are offered as candidates, and
|
||||
* still need have the content type requested (via file extension, parameter, or {@code Accept} header, described above).
|
||||
* You can also set the {@linkplain #setDefaultContentType(MediaType) default content type} directly, which will be
|
||||
* returned when the other mechanisms ({@code Accept} header, file extension or parameter) do not result in a match.
|
||||
* <p>Additionally, this view resolver exposes the {@link #setDefaultViews(List) defaultViews} property,
|
||||
* allowing you to override the views provided by the view resolvers. Note that these default views are
|
||||
* offered as candidates, and still need have the content type requested (via file extension, parameter,
|
||||
* or {@code Accept} header, described above).
|
||||
*
|
||||
* <p>For example, if the request path is {@code /view.html}, this view resolver will look for a view that has the
|
||||
* {@code text/html} content type (based on the {@code html} file extension). A request for {@code /view} with a {@code
|
||||
* text/html} request {@code Accept} header has the same result.
|
||||
* <p>For example, if the request path is {@code /view.html}, this view resolver will look for a view
|
||||
* that has the {@code text/html} content type (based on the {@code html} file extension). A request
|
||||
* for {@code /view} with a {@code text/html} request {@code Accept} header has the same result.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ import org.springframework.web.servlet.view.AbstractView;
|
||||
* </ul>
|
||||
*
|
||||
* <p>For working with the workbook in the subclass, see
|
||||
* <a href="http://jakarta.apache.org/poi/index.html">Jakarta's POI site</a>
|
||||
* <a href="http://poi.apache.org">Apache's POI site</a>
|
||||
*
|
||||
* <p>As an example, you can try this snippet:
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user