Update API version and package references for Jakarta EE 9
Closes gh-27689 See gh-25354
This commit is contained in:
@@ -29,7 +29,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link ServerHttpAsyncRequestControl} to use on Servlet containers (Servlet 3.0+).
|
||||
* A {@link ServerHttpAsyncRequestControl} to use on Servlet containers.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
@@ -62,7 +62,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||
"Async support must be enabled on a servlet and for all filters involved " +
|
||||
"in async request processing. This is done in Java code using the Servlet API " +
|
||||
"or by adding \"<async-supported>true</async-supported>\" to servlet and " +
|
||||
"filter declarations in web.xml. Also you must use a Servlet 3.0+ container");
|
||||
"filter declarations in web.xml.");
|
||||
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
|
||||
* event-listener read APIs and Reactive Streams.
|
||||
*
|
||||
* <p>Specifically a base class for reading from the HTTP request body with
|
||||
* Servlet 3.1 non-blocking I/O and Undertow XNIO as well as handling incoming
|
||||
* Servlet non-blocking I/O and Undertow XNIO as well as handling incoming
|
||||
* WebSocket messages with standard Java WebSocket (JSR-356), Jetty, and
|
||||
* Undertow.
|
||||
*
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* Abstract base class for listener-based server responses, e.g. Servlet 3.1
|
||||
* and Undertow.
|
||||
* Abstract base class for listener-based server responses.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 5.0
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.StringUtils;
|
||||
* event-listener write APIs and Reactive Streams.
|
||||
*
|
||||
* <p>Specifically a base class for writing to the HTTP response body with
|
||||
* Servlet 3.1 non-blocking I/O and Undertow XNIO as well for writing WebSocket
|
||||
* Servlet non-blocking I/O and Undertow XNIO as well for writing WebSocket
|
||||
* messages through the Java WebSocket API (JSR-356), Jetty, and Undertow.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adapt {@link HttpHandler} to an {@link HttpServlet} using Servlet Async support
|
||||
* and Servlet 3.1 non-blocking I/O.
|
||||
* and Servlet non-blocking I/O.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* {@link org.springframework.http.server.reactive.HttpHandler} for processing.
|
||||
*
|
||||
* <p>Also provides implementations adapting to different runtimes
|
||||
* including Servlet 3.1 containers, Netty + Reactor IO, and Undertow.
|
||||
* including Servlet containers, Netty + Reactor IO, and Undertow.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -33,21 +33,18 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Servlet 3.0 {@link ServletContainerInitializer} designed to support code-based
|
||||
* A Spring-provided {@link ServletContainerInitializer} designed to support code-based
|
||||
* configuration of the servlet container using Spring's {@link WebApplicationInitializer}
|
||||
* SPI as opposed to (or possibly in combination with) the traditional
|
||||
* {@code web.xml}-based approach.
|
||||
*
|
||||
* <h2>Mechanism of Operation</h2>
|
||||
* This class will be loaded and instantiated and have its {@link #onStartup}
|
||||
* method invoked by any Servlet 3.0-compliant container during container startup assuming
|
||||
* method invoked by any Servlet-compliant container during container startup assuming
|
||||
* that the {@code spring-web} module JAR is present on the classpath. This occurs through
|
||||
* the JAR Services API {@link ServiceLoader#load(Class)} method detecting the
|
||||
* {@code spring-web} module's {@code META-INF/services/jakarta.servlet.ServletContainerInitializer}
|
||||
* service provider configuration file. See the
|
||||
* <a href="https://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider">
|
||||
* JAR Services API documentation</a> as well as section <em>8.2.4</em> of the Servlet 3.0
|
||||
* Final Draft specification for complete details.
|
||||
* service provider configuration file.
|
||||
*
|
||||
* <h3>In combination with {@code web.xml}</h3>
|
||||
* A web application can choose to limit the amount of classpath scanning the Servlet
|
||||
@@ -80,12 +77,12 @@ import org.springframework.util.ReflectionUtils;
|
||||
* <h2>General Notes</h2>
|
||||
* In general, this class should be viewed as <em>supporting infrastructure</em> for
|
||||
* the more important and user-facing {@code WebApplicationInitializer} SPI. Taking
|
||||
* advantage of this container initializer is also completely <em>optional</em>: while
|
||||
* it is true that this initializer will be loaded and invoked under all Servlet 3.0+
|
||||
* runtimes, it remains the user's choice whether to make any
|
||||
* {@code WebApplicationInitializer} implementations available on the classpath. If no
|
||||
* {@code WebApplicationInitializer} types are detected, this container initializer will
|
||||
* have no effect.
|
||||
* advantage of this container initializer is also completely <em>optional</em>:
|
||||
* while it is true that this initializer will be loaded and invoked under all
|
||||
* Servlet runtimes, it remains the user's choice whether to make any
|
||||
* {@code WebApplicationInitializer} implementations available on the classpath.
|
||||
* If no {@code WebApplicationInitializer} types are detected, this container
|
||||
* initializer will have no effect.
|
||||
*
|
||||
* <p>Note that use of this container initializer and of {@code WebApplicationInitializer}
|
||||
* is not in any way "tied" to Spring MVC other than the fact that the types are shipped
|
||||
@@ -117,8 +114,8 @@ public class SpringServletContainerInitializer implements ServletContainerInitia
|
||||
* Delegate the {@code ServletContext} to any {@link WebApplicationInitializer}
|
||||
* implementations present on the application classpath.
|
||||
* <p>Because this class declares @{@code HandlesTypes(WebApplicationInitializer.class)},
|
||||
* Servlet 3.0+ containers will automatically scan the classpath for implementations
|
||||
* of Spring's {@code WebApplicationInitializer} interface and provide the set of all
|
||||
* Servlet containers will automatically scan the classpath for implementations of
|
||||
* Spring's {@code WebApplicationInitializer} interface and provide the set of all
|
||||
* such types to the {@code webAppInitializerClasses} parameter of this method.
|
||||
* <p>If no {@code WebApplicationInitializer} implementations are found on the classpath,
|
||||
* this method is effectively a no-op. An INFO-level log message will be issued notifying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -20,13 +20,13 @@ import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
/**
|
||||
* Interface to be implemented in Servlet 3.0+ environments in order to configure the
|
||||
* Interface to be implemented in Servlet environments in order to configure the
|
||||
* {@link ServletContext} programmatically -- as opposed to (or possibly in conjunction
|
||||
* with) the traditional {@code web.xml}-based approach.
|
||||
*
|
||||
* <p>Implementations of this SPI will be detected automatically by {@link
|
||||
* SpringServletContainerInitializer}, which itself is bootstrapped automatically
|
||||
* by any Servlet 3.0 container. See {@linkplain SpringServletContainerInitializer its
|
||||
* by any Servlet container. See {@linkplain SpringServletContainerInitializer its
|
||||
* Javadoc} for details on this bootstrapping mechanism.
|
||||
*
|
||||
* <h2>Example</h2>
|
||||
@@ -74,10 +74,10 @@ import jakarta.servlet.ServletException;
|
||||
* As an alternative to the above, you can also extend from {@link
|
||||
* org.springframework.web.servlet.support.AbstractDispatcherServletInitializer}.
|
||||
*
|
||||
* As you can see, thanks to Servlet 3.0's new {@link ServletContext#addServlet} method
|
||||
* we're actually registering an <em>instance</em> of the {@code DispatcherServlet}, and
|
||||
* this means that the {@code DispatcherServlet} can now be treated like any other object
|
||||
* -- receiving constructor injection of its application context in this case.
|
||||
* As you can see, thanks to the Servlet container's {@link ServletContext#addServlet}
|
||||
* method we're actually registering an <em>instance</em> of the {@code DispatcherServlet},
|
||||
* and this means that the {@code DispatcherServlet} can now be treated like any other
|
||||
* object -- receiving constructor injection of its application context in this case.
|
||||
*
|
||||
* <p>This style is both simpler and more concise. There is no concern for dealing with
|
||||
* init-params, etc, just normal JavaBean-style properties and constructor arguments. You
|
||||
@@ -89,8 +89,8 @@ import jakarta.servlet.ServletException;
|
||||
* {@code ContextLoaderListener} and {@code DelegatingFilterProxy} all now support
|
||||
* constructor arguments. Even if a component (e.g. non-Spring, other third party) has not
|
||||
* been specifically updated for use within {@code WebApplicationInitializers}, they still
|
||||
* may be used in any case. The Servlet 3.0 {@code ServletContext} API allows for setting
|
||||
* init-params, context-params, etc programmatically.
|
||||
* may be used in any case. The {@code ServletContext} API allows for setting init-params,
|
||||
* context-params, etc programmatically.
|
||||
*
|
||||
* <h2>A 100% code-based approach to configuration</h2>
|
||||
* In the example above, {@code WEB-INF/web.xml} was successfully replaced with code in
|
||||
@@ -149,24 +149,6 @@ import jakarta.servlet.ServletException;
|
||||
* occurs. Use of this feature is expected to be rare, as typical applications will likely
|
||||
* centralize all container initialization within a single {@code WebApplicationInitializer}.
|
||||
*
|
||||
* <h2>Caveats</h2>
|
||||
*
|
||||
* <h3>web.xml versioning</h3>
|
||||
* <p>{@code WEB-INF/web.xml} and {@code WebApplicationInitializer} use are not mutually
|
||||
* exclusive; for example, web.xml can register one servlet, and a {@code
|
||||
* WebApplicationInitializer} can register another. An initializer can even
|
||||
* <em>modify</em> registrations performed in {@code web.xml} through methods such as
|
||||
* {@link ServletContext#getServletRegistration(String)}. <strong>However, if
|
||||
* {@code WEB-INF/web.xml} is present in the application, its {@code version} attribute
|
||||
* must be set to "3.0" or greater, otherwise {@code ServletContainerInitializer}
|
||||
* bootstrapping will be ignored by the servlet container.</strong>
|
||||
*
|
||||
* <h3>Mapping to '/' under Tomcat</h3>
|
||||
* <p>Apache Tomcat maps its internal {@code DefaultServlet} to "/", and on Tomcat versions
|
||||
* <= 7.0.14, this servlet mapping <em>cannot be overridden programmatically</em>.
|
||||
* 7.0.15 fixes this issue. Overriding the "/" servlet mapping has also been tested
|
||||
* successfully under GlassFish 3.1.<p>
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see SpringServletContainerInitializer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
*
|
||||
* <p>Supported method argument types include {@link MultipartFile} in conjunction with
|
||||
* Spring's {@link MultipartResolver} abstraction, {@code jakarta.servlet.http.Part} in
|
||||
* conjunction with Servlet 3.0 multipart requests, or otherwise for any other method
|
||||
* conjunction with Servlet multipart requests, or otherwise for any other method
|
||||
* argument, the content of the part is passed through an {@link HttpMessageConverter}
|
||||
* taking into consideration the 'Content-Type' header of the request part. This is
|
||||
* analogous to what @{@link RequestBody} does to resolve an argument based on the
|
||||
|
||||
@@ -72,7 +72,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* <p>As of Spring 3.1, {@code ContextLoader} supports injecting the root web
|
||||
* application context via the {@link #ContextLoader(WebApplicationContext)}
|
||||
* constructor, allowing for programmatic configuration in Servlet 3.0+ environments.
|
||||
* constructor, allowing for programmatic configuration in Servlet initializers.
|
||||
* See {@link org.springframework.web.WebApplicationInitializer} for usage examples.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -193,9 +193,8 @@ public class ContextLoader {
|
||||
|
||||
/**
|
||||
* Create a new {@code ContextLoader} with the given application context. This
|
||||
* constructor is useful in Servlet 3.0+ environments where instance-based
|
||||
* registration of listeners is possible through the {@link ServletContext#addListener}
|
||||
* API.
|
||||
* constructor is useful in Servlet initializers where instance-based registration
|
||||
* of listeners is possible through the {@link ServletContext#addListener} API.
|
||||
* <p>The context may or may not yet be {@linkplain
|
||||
* ConfigurableApplicationContext#refresh() refreshed}. If it (a) is an implementation
|
||||
* of {@link ConfigurableWebApplicationContext} and (b) has <strong>not</strong>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -25,7 +25,7 @@ import jakarta.servlet.ServletContextListener;
|
||||
*
|
||||
* <p>As of Spring 3.1, {@code ContextLoaderListener} supports injecting the root web
|
||||
* application context via the {@link #ContextLoaderListener(WebApplicationContext)}
|
||||
* constructor, allowing for programmatic configuration in Servlet 3.0+ environments.
|
||||
* constructor, allowing for programmatic configuration in Servlet initializers.
|
||||
* See {@link org.springframework.web.WebApplicationInitializer} for usage examples.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -58,9 +58,8 @@ public class ContextLoaderListener extends ContextLoader implements ServletConte
|
||||
|
||||
/**
|
||||
* Create a new {@code ContextLoaderListener} with the given application context. This
|
||||
* constructor is useful in Servlet 3.0+ environments where instance-based
|
||||
* registration of listeners is possible through the {@link jakarta.servlet.ServletContext#addListener}
|
||||
* API.
|
||||
* constructor is useful in Servlet initializers where instance-based registration of
|
||||
* listeners is possible through the {@link jakarta.servlet.ServletContext#addListener} API.
|
||||
* <p>The context may or may not yet be {@linkplain
|
||||
* org.springframework.context.ConfigurableApplicationContext#refresh() refreshed}. If it
|
||||
* (a) is an implementation of {@link ConfigurableWebApplicationContext} and
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
/**
|
||||
* A Servlet 3.0 implementation of {@link AsyncWebRequest}.
|
||||
* A Servlet implementation of {@link AsyncWebRequest}.
|
||||
*
|
||||
* <p>The servlet and all filters involved in an async request must have async
|
||||
* support enabled using the Servlet API or by adding an
|
||||
|
||||
@@ -54,9 +54,9 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
* of the {@code Filter.init} and {@code Filter.destroy} lifecycle methods
|
||||
* on the target bean, letting the servlet container manage the filter lifecycle.
|
||||
*
|
||||
* <p>As of Spring 3.1, {@code DelegatingFilterProxy} has been updated to optionally accept
|
||||
* constructor parameters when using Servlet 3.0's instance-based filter registration
|
||||
* methods, usually in conjunction with Spring 3.1's
|
||||
* <p>As of Spring 3.1, {@code DelegatingFilterProxy} has been updated to optionally
|
||||
* accept constructor parameters when using a Servlet container's instance-based filter
|
||||
* registration methods, usually in conjunction with Spring's
|
||||
* {@link org.springframework.web.WebApplicationInitializer} SPI. These constructors allow
|
||||
* for providing the delegate Filter bean directly, or providing the application context
|
||||
* and bean name to fetch, avoiding the need to look up the application context from the
|
||||
@@ -100,8 +100,7 @@ public class DelegatingFilterProxy extends GenericFilterBean {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code DelegatingFilterProxy}. For traditional (pre-Servlet 3.0) use
|
||||
* in {@code web.xml}.
|
||||
* Create a new {@code DelegatingFilterProxy}. For traditional use in {@code web.xml}.
|
||||
* @see #setTargetBeanName(String)
|
||||
*/
|
||||
public DelegatingFilterProxy() {
|
||||
@@ -111,8 +110,7 @@ public class DelegatingFilterProxy extends GenericFilterBean {
|
||||
* Create a new {@code DelegatingFilterProxy} with the given {@link Filter} delegate.
|
||||
* Bypasses entirely the need for interacting with a Spring application context,
|
||||
* specifying the {@linkplain #setTargetBeanName target bean name}, etc.
|
||||
* <p>For use in Servlet 3.0+ environments where instance-based registration of
|
||||
* filters is supported.
|
||||
* <p>For use with instance-based registration of filters.
|
||||
* @param delegate the {@code Filter} instance that this proxy will delegate to and
|
||||
* manage the lifecycle for (must not be {@code null}).
|
||||
* @see #doFilter(ServletRequest, ServletResponse, FilterChain)
|
||||
@@ -130,9 +128,8 @@ public class DelegatingFilterProxy extends GenericFilterBean {
|
||||
* bean from the Spring {@code WebApplicationContext} found in the {@code ServletContext}
|
||||
* (either the 'root' application context or the context named by
|
||||
* {@link #setContextAttribute}).
|
||||
* <p>For use in Servlet 3.0+ environments where instance-based registration of
|
||||
* filters is supported.
|
||||
* <p>The target bean must implement the standard Servlet Filter.
|
||||
* <p>For use with instance-based registration of filters.
|
||||
* <p>The target bean must implement the standard Servlet Filter interface.
|
||||
* @param targetBeanName name of the target filter bean to look up in the Spring
|
||||
* application context (must not be {@code null}).
|
||||
* @see #findWebApplicationContext()
|
||||
@@ -145,8 +142,7 @@ public class DelegatingFilterProxy extends GenericFilterBean {
|
||||
/**
|
||||
* Create a new {@code DelegatingFilterProxy} that will retrieve the named target
|
||||
* bean from the given Spring {@code WebApplicationContext}.
|
||||
* <p>For use in Servlet 3.0+ environments where instance-based registration of
|
||||
* filters is supported.
|
||||
* <p>For use with instance-based registration of filters.
|
||||
* <p>The target bean must implement the standard Servlet Filter interface.
|
||||
* <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
|
||||
* in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.web.util.WebUtils;
|
||||
* dispatch, on any servlet container. It provides a {@link #doFilterInternal}
|
||||
* method with HttpServletRequest and HttpServletResponse arguments.
|
||||
*
|
||||
* <p>As of Servlet 3.0, a filter may be invoked as part of a
|
||||
* <p>A filter may be invoked as part of a
|
||||
* {@link jakarta.servlet.DispatcherType#REQUEST REQUEST} or
|
||||
* {@link jakarta.servlet.DispatcherType#ASYNC ASYNC} dispatches that occur in
|
||||
* separate threads. A filter can be configured in {@code web.xml} whether it
|
||||
@@ -133,10 +133,10 @@ public abstract class OncePerRequestFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
/**
|
||||
* The dispatcher type {@code jakarta.servlet.DispatcherType.ASYNC} introduced
|
||||
* in Servlet 3.0 means a filter can be invoked in more than one thread over
|
||||
* the course of a single request. This method returns {@code true} if the
|
||||
* filter is currently executing within an asynchronous dispatch.
|
||||
* The dispatcher type {@code jakarta.servlet.DispatcherType.ASYNC} means a
|
||||
* filter can be invoked in more than one thread over the course of a single
|
||||
* request. This method returns {@code true} if the filter is currently
|
||||
* executing within an asynchronous dispatch.
|
||||
* @param request the current request
|
||||
* @since 3.2
|
||||
* @see WebAsyncManager#hasConcurrentResult()
|
||||
@@ -186,15 +186,15 @@ public abstract class OncePerRequestFilter extends GenericFilterBean {
|
||||
}
|
||||
|
||||
/**
|
||||
* The dispatcher type {@code jakarta.servlet.DispatcherType.ASYNC} introduced
|
||||
* in Servlet 3.0 means a filter can be invoked in more than one thread
|
||||
* over the course of a single request. Some filters only need to filter
|
||||
* the initial thread (e.g. request wrapping) while others may need
|
||||
* to be invoked at least once in each additional thread for example for
|
||||
* setting up thread locals or to perform final processing at the very end.
|
||||
* The dispatcher type {@code jakarta.servlet.DispatcherType.ASYNC} means a
|
||||
* filter can be invoked in more than one thread over the course of a single
|
||||
* request. Some filters only need to filter the initial thread (e.g. request
|
||||
* wrapping) while others may need to be invoked at least once in each
|
||||
* additional thread for example for setting up thread locals or to perform
|
||||
* final processing at the very end.
|
||||
* <p>Note that although a filter can be mapped to handle specific dispatcher
|
||||
* types via {@code web.xml} or in Java through the {@code ServletContext},
|
||||
* servlet containers may enforce different defaults with regards to
|
||||
* servlet containers may enforce different defaults with respect to
|
||||
* dispatcher types. This flag enforces the design intent of the filter.
|
||||
* <p>The default return value is "true", which means the filter will not be
|
||||
* invoked during subsequent async dispatches. If "false", the filter will
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -46,9 +46,6 @@ import org.springframework.web.util.WebUtils;
|
||||
* (e.g. a {@link org.springframework.web.servlet.View}) is still rendered.
|
||||
* As such, this filter only saves bandwidth, not server performance.
|
||||
*
|
||||
* <p><b>NOTE:</b> As of Spring Framework 5.0, this filter uses request/response
|
||||
* decorators built on the Servlet 3.1 API.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* Resolves method arguments annotated with @{@link RequestParam}, arguments of
|
||||
* type {@link MultipartFile} in conjunction with Spring's {@link MultipartResolver}
|
||||
* abstraction, and arguments of type {@code jakarta.servlet.http.Part} in conjunction
|
||||
* with Servlet 3.0 multipart requests. This resolver can also be created in default
|
||||
* with Servlet multipart requests. This resolver can also be created in default
|
||||
* resolution mode in which simple types (int, long, etc.) not annotated with
|
||||
* {@link RequestParam @RequestParam} are also treated as request parameters with
|
||||
* the parameter name derived from the argument name.
|
||||
|
||||
@@ -124,7 +124,7 @@ public interface MultipartFile extends InputStreamSource {
|
||||
* in order to work with any storage mechanism.
|
||||
* <p><b>NOTE:</b> Depending on the underlying provider, temporary storage
|
||||
* may be container-dependent, including the base directory for relative
|
||||
* destinations specified here (e.g. with Servlet 3.0 multipart handling).
|
||||
* destinations specified here (e.g. with Servlet multipart handling).
|
||||
* For absolute destinations, the target file may get renamed/moved from its
|
||||
* temporary location or newly copied, even if a temporary copy already exists.
|
||||
* @param dest the destination file (typically absolute)
|
||||
|
||||
@@ -27,7 +27,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
* <p>Spring provides the following concrete implementation:
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.web.multipart.support.StandardServletMultipartResolver}
|
||||
* for the Servlet 3.0+ Part API
|
||||
* for the Servlet Part API
|
||||
* </ul>
|
||||
*
|
||||
* <p>There is no default resolver implementation used for Spring
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -38,8 +38,8 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
* the default bean name is "filterMultipartResolver".
|
||||
*
|
||||
* <p>If no MultipartResolver bean is found, this filter falls back to a default
|
||||
* MultipartResolver: {@link StandardServletMultipartResolver} for Servlet 3.0,
|
||||
* based on a multipart-config section in {@code web.xml}.
|
||||
* MultipartResolver: {@link StandardServletMultipartResolver} for Servlet
|
||||
* oontainers, based on a multipart-config section in {@code web.xml}.
|
||||
* Note however that at present the Servlet specification only defines how to
|
||||
* enable multipart configuration on a Servlet and as a result multipart request
|
||||
* processing is likely not possible in a Filter unless the Servlet container
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
/**
|
||||
* {@link ServerHttpRequest} implementation that accesses one part of a multipart
|
||||
* request. If using {@link MultipartResolver} configuration the part is accessed
|
||||
* through a {@link MultipartFile}. Or if using Servlet 3.0 multipart processing
|
||||
* through a {@link MultipartFile}. Or if using Servlet multipart processing
|
||||
* the part is accessed through {@code ServletRequest.getPart}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.multipart.MultipartException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* Spring MultipartHttpServletRequest adapter, wrapping a Servlet 3.0 HttpServletRequest
|
||||
* Spring MultipartHttpServletRequest adapter, wrapping a Servlet HttpServletRequest
|
||||
* and its Part objects. Parameters get exposed through the native request's getParameter
|
||||
* methods - without any custom processing on our side.
|
||||
*
|
||||
@@ -138,7 +138,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
return super.getParameterNames();
|
||||
}
|
||||
|
||||
// Servlet 3.0 getParameterNames() not guaranteed to include multipart form items
|
||||
// Servlet getParameterNames() not guaranteed to include multipart form items
|
||||
// (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
|
||||
Set<String> paramNames = new LinkedHashSet<>();
|
||||
Enumeration<String> paramEnum = super.getParameterNames();
|
||||
@@ -158,7 +158,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
return super.getParameterMap();
|
||||
}
|
||||
|
||||
// Servlet 3.0 getParameterMap() not guaranteed to include multipart form items
|
||||
// Servlet getParameterMap() not guaranteed to include multipart form items
|
||||
// (e.g. on WebLogic 12) -> need to merge them here to be on the safe side
|
||||
Map<String, String[]> paramMap = new LinkedHashMap<>(super.getParameterMap());
|
||||
for (String paramName : this.multipartParameterNames) {
|
||||
@@ -202,7 +202,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
|
||||
|
||||
/**
|
||||
* Spring MultipartFile adapter, wrapping a Servlet 3.0 Part object.
|
||||
* Spring MultipartFile adapter, wrapping a Servlet Part object.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static class StandardMultipartFile implements MultipartFile, Serializable {
|
||||
@@ -255,7 +255,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
this.part.write(dest.getPath());
|
||||
if (dest.isAbsolute() && !dest.exists()) {
|
||||
// Servlet 3.0 Part.write is not guaranteed to support absolute file paths:
|
||||
// Servlet Part.write is not guaranteed to support absolute file paths:
|
||||
// may translate the given path to a relative location within a temp dir
|
||||
// (e.g. on Jetty whereas Tomcat and Undertow detect absolute paths).
|
||||
// At least we offloaded the file from memory storage; it'll get deleted
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
|
||||
/**
|
||||
* Standard implementation of the {@link MultipartResolver} interface,
|
||||
* based on the Servlet 3.0 {@link jakarta.servlet.http.Part} API.
|
||||
* based on the Servlet {@link jakarta.servlet.http.Part} API.
|
||||
* To be added as "multipartResolver" bean to a Spring DispatcherServlet context,
|
||||
* without any extra configuration at the bean level (see below).
|
||||
*
|
||||
@@ -38,14 +38,14 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||
* {@linkplain #setStrictServletCompliance strict Servlet compliance}, narrowing the
|
||||
* applicability of Spring's {@link MultipartHttpServletRequest} to form data only.
|
||||
*
|
||||
* <p><b>Note:</b> In order to use Servlet 3.0 based multipart parsing,
|
||||
* <p><b>Note:</b> In order to use Servlet container based multipart parsing,
|
||||
* you need to mark the affected servlet with a "multipart-config" section in
|
||||
* {@code web.xml}, or with a {@link jakarta.servlet.MultipartConfigElement}
|
||||
* in programmatic servlet registration, or (in case of a custom servlet class)
|
||||
* possibly with a {@link jakarta.servlet.annotation.MultipartConfig} annotation
|
||||
* on your servlet class. Configuration settings such as maximum sizes or
|
||||
* storage locations need to be applied at that servlet registration level;
|
||||
* Servlet 3.0 does not allow for them to be set at the MultipartResolver level.
|
||||
* on your servlet class. Configuration settings such as maximum sizes or storage
|
||||
* locations need to be applied at that servlet registration level; a Servlet
|
||||
* container does not allow for them to be set at the MultipartResolver level.
|
||||
*
|
||||
* <pre class="code">
|
||||
* public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
@@ -46,8 +46,6 @@ import org.springframework.lang.Nullable;
|
||||
* retrieved via {@link #getContentAsByteArray()}.
|
||||
*
|
||||
* <p>Used e.g. by {@link org.springframework.web.filter.AbstractRequestLoggingFilter}.
|
||||
* Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.
|
||||
*
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Brian Clozel
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -37,7 +37,6 @@ import org.springframework.util.FastByteArrayOutputStream;
|
||||
* and allows this content to be retrieved via a {@link #getContentAsByteArray() byte array}.
|
||||
*
|
||||
* <p>Used e.g. by {@link org.springframework.web.filter.ShallowEtagHeaderFilter}.
|
||||
* Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.1.3
|
||||
@@ -128,7 +127,6 @@ public class ContentCachingResponseWrapper extends HttpServletResponseWrapper {
|
||||
this.contentLength = len;
|
||||
}
|
||||
|
||||
// Overrides Servlet 3.1 setContentLengthLong(long) at runtime
|
||||
@Override
|
||||
public void setContentLengthLong(long len) {
|
||||
if (len > Integer.MAX_VALUE) {
|
||||
|
||||
Reference in New Issue
Block a user