The Spring MVC programming model now provides explicit Servlet 3 async support.
@RequestMapping methods can return one of:
complete processing in a separate thread managed by a task executor
within Spring MVC.
to complete processing at a later time from a thread not known to
Spring MVC, e.g. in response to some external event (JSM, AMQP, etc.)
to wrap a
customize the timeout value or the task executor to use.
See Introducing Servlet 3 Async Support (SpringSource team blog).
First-class support for testing Spring MVC applications with a
fluent API and without a servlet container. Server-side tests involve
use of the
DispatcherServlet while client-side
REST tests rely on the
See the following presentation for more information before
documentation is added:
"Testing Web Applications with Spring 3.2".
ContentNeogtiationStrategy is now
available for resolving the requested media types from an incoming request.
The available implementations are based on path extension, request parameter,
'Accept' header, and a fixed default content type. Equivalent options were
previously available only in the ContentNegotiatingViewResolver but are now
ContentNegotiationManager is the central class to
use when configuring content negotiation options. It accepts one or
more ContentNeogtiationStrategy instances and delegates to them. It can be
ContentNegotiatingViewResolver. The MVC
namespace and the MVC Java config provide convenient options to configure
The introduction of
also enables smart suffix pattern matching for incoming requests.
Classes annotated with
@ModelAttribute methods and those will apply
@RequestMapping methods across controller
hierarchies as opposed to the controller hierarchy within which they are declared.
a component annotation allowing implementation classes to be auto-detected
through classpath scanning.
adds support for extracting matrix variables from the request URI.
For more details see Section 126.96.36.199, “Matrix Variables”.
An abstract base class implementation of the
WebApplicationInitializer interface is provided to
simplify code-based registration of a DispatcherServlet and filters
mapped to it. The new class is named
AbstractDispatcherServletInitializer and its
can be used with Java-based Spring configuration.
For more details see Section 17.14, “Code-based Servlet container initialization”.
A convenient base class with an
method that handles standard Spring MVC exceptions and returns a
ResponseEntity that allowing customizing and writing
the response with HTTP message converters. This servers as an alternative
DefaultHandlerExceptionResolver, which does
the same but returns a
See the revised Section 17.11, “Handling exceptions” including information on customizing the default Servlet container error page.
RestTemplate can now read an HTTP
response to a generic type (e.g.
There are three new
exchange() methods that accept
new class that enables capturing and passing generic type info.
In support of this feature, the
is extended by
adding a method for reading content given a specified parameterized type.
The new interface is implemented by the
MappingJacksonHttpMessageConverter and also
by a new
Jaxb2CollectionHttpMessageConverter that can
read read a generic
Collection where the
generic type is a JAXB type annotated with
The Jackson Json 2 library is now supported. Due to packaging changes in
the Jackson library, there are separate classes in Spring MVC as well. Those are
Other related configuration improvements include support for
pretty printing as well as a
JacksonObjectMapperFactoryBean for convenient
customization of an
@RequestBody or an
@RequestPart argument can now be followed by an
Errors argument making it possible to handle
validation errors (as a result of an
annotation) locally within the
@RequestBody now also supports
a required flag.
The HTTP request method
PATCH may now be used in
@RequestMapping methods as well as in
RestTemplate in conjunction with
Apache HttpComponents HttpClient version 4.2 or later.
HttpURLConnection does not support the
Mapped interceptors now support URL patterns to be excluded. The MVC namespace and the MVC Java config both expose these options.
@DateTimeFormat annotation can now be
used without needing a dependency on the Joda Time library. If Joda Time is not
present the JDK
SimpleDateFormat will be used to parse and
print date patterns. When Joda time is present it will continue to be used in
It is now possible to define global formats that will be used when parsing and printing date and time types. See Section 7.7, “Configuring a global date & time format” for details.