Update the what's new section
This commit is contained in:
parent
abc343f407
commit
3a8f30613d
|
@ -1046,56 +1046,76 @@ method has been added.
|
|||
|
||||
=== Web Improvements
|
||||
|
||||
* The existing support for resource handling based on the `ResourceHttpRequestHandler`
|
||||
has been expanded with new abstractions `ResourceResolver`, `ResourceTransformer`,
|
||||
and `ResourceUrlProvider`. A number of built-in implementations provide support
|
||||
for versioned resource URLs (for effective HTTP caching), locating gzipped resources,
|
||||
generating an HTML 5 AppCache manifests, and more.
|
||||
* JDK 1.8's `java.util.Optional` is now supported for `@RequestParam`, `@RequestHeader`,
|
||||
and `@MatrixVariable` controller method arguments, while `ListenableFuture` is supported as
|
||||
a return value alternative to `DeferredResult` where an underlying service (or perhaps a
|
||||
call to `AsyncRestTemplate`) already returns `ListenableFuture`.
|
||||
and `@MatrixVariable` controller method arguments.
|
||||
* `ListenableFuture` is supported as a return value alternative to `DeferredResult`
|
||||
where an underlying service (or perhaps a call to `AsyncRestTemplate`) already
|
||||
returns `ListenableFuture`.
|
||||
* `@ModelAttribute` methods are now invoked in an order that respects inter-dependencies.
|
||||
See jira.springsource.org/browse/SPR-6299[SPR-6299].
|
||||
* Jackson's `@JsonView` is supported directly on `@ResponseBody` and `ResponseEntity`
|
||||
controller methods for serializing different amounts of detail for the same POJO -- for
|
||||
example, summary vs. detail page. This is also supported with View-based rendering by
|
||||
controller methods for serializing different amounts of detail for the same POJO (e.g.
|
||||
summary vs. detail page). This is also supported with View-based rendering by
|
||||
adding the serialization view type as a model attribute under a special key.
|
||||
See <<mvc-ann-jsonview>> for details.
|
||||
* Jackson based XML serialization is now supported using
|
||||
https://github.com/FasterXML/jackson-dataformat-xml[jackson-dataformat-xml] extension.
|
||||
When using `@EnableWebMvc` or `<mvc:annotation-driven/>`, Jackson will be used by default
|
||||
instead of JAXB2 if `jackson-dataformat-xml` classes are found in the classpath.
|
||||
* JSONP is now supported with Jackson.
|
||||
* A `@ControllerAdvice` can now also implement `ResponseBodyAdvice` in which case it will be
|
||||
called after the controller method returns but before the response is written and
|
||||
therefore committed. This has a number of useful applications with `@JsonView` and
|
||||
JSONP already serving as two examples built on it.
|
||||
* Two new `HttpMessageConverter` types:
|
||||
* A new lifecycle option is available for intercepting `@ResponseBody` and `ResponseEntity`
|
||||
methods just after the controller method returns and before the response is written.
|
||||
To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`.
|
||||
The built-in support for `@JsonView` and JSONP take advantage of this.
|
||||
* There are three new `HttpMessageConverter` options:
|
||||
** Gson -- lighter footprint than Jackson; has already been in use in Spring Android.
|
||||
** Google Protocol Buffers -- efficient and effective as an inter-service communication
|
||||
data protocol within an enterprise but can also be exposed as JSON and XML for browsers.
|
||||
This comes through a contribution from
|
||||
http://www.slideshare.net/mokeefe/javaone-2009-ts5276-restful-protocol-buffers[Alex Antonov].
|
||||
* `MvcUriComponentsBuilder` was introduced in 4.0 as a way of building links to controller
|
||||
methods through controller method invocation (similar to mock testing). In 4.1 views such
|
||||
as JSPs can also build links to controllers by referring to their mappings by name.
|
||||
A default name is assigned to every `@RequestMapping`. For example `FooController` with method
|
||||
`handleFoo` is assigned "FC#handleFoo" by default but the naming strategy is customizable
|
||||
and can be also be set explicitly through the new `name` attribute on `@RequestMapping`.
|
||||
A new `mvcUrl` Spring JSP tag makes this easy to use in JSP pages.
|
||||
The same can be done for any other view technology.
|
||||
* The familiar `ResponseEntity` now has a builder-style API that guides controller methods
|
||||
** Jackson based XML serialization is now supported through the
|
||||
https://github.com/FasterXML/jackson-dataformat-xml[jackson-dataformat-xml] extension.
|
||||
When using `@EnableWebMvc` or `<mvc:annotation-driven/>`, this is used by default
|
||||
instead of JAXB2 if `jackson-dataformat-xml` is in the classpath.
|
||||
* Views such as JSPs can now build links to controllers by referring to controller mappings
|
||||
by name. A default name is assigned to every `@RequestMapping`. For example `FooController`
|
||||
with method `handleFoo` is named "FC#handleFoo". The naming strategy is pluggable.
|
||||
It is also possible to name an `@RequestMapping` explicitly through its name attribute.
|
||||
A new `mvcUrl` function in the Spring JSP tag library makes this easy to use in JSP pages.
|
||||
* `ResponseEntity` provides a builder-style API to guide controller methods
|
||||
towards the preparation of server-side responses, e.g. `ResponseEntity.ok()`.
|
||||
For the client side there is a new `RequestEntity` also offering a builder-style API that
|
||||
guides towards the preparation of client-side HTTP requests.
|
||||
* `RequestEntity` is a new type that provides a builder-style API to guide client-side REST
|
||||
code towards the preparation of HTTP requests.
|
||||
* MVC Java config and XML namespace:
|
||||
** View resolver configuration -- if you've had to configure view resolution with content
|
||||
negotiation you'll likely appreciate this one. See <<mvc-config-view-resolvers>> for
|
||||
details.
|
||||
** Enhanced "view controllers" -- in addition to mapping URLs directly to view names
|
||||
without the need for controller logic, view controllers now have built-in support for
|
||||
redirecting and setting the response status. An application can use this to configure
|
||||
redirect URLs, render 404 responses with a view, send "no content" responses, etc.
|
||||
Some use cases are https://jira.spring.io/browse/SPR-11543?focusedCommentId=100308&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-100308[listed here].
|
||||
** Path matching -- these frequently used customizations are now built-in and have also been
|
||||
backported to 4.0. See <<mvc-config-path-matching>> for details.
|
||||
** View resolvers can now be configured including support for content
|
||||
negotiation, see <<mvc-config-view-resolvers>>.
|
||||
** View controllers now have built-in support for redirects and for setting the response
|
||||
status. An application can use this to configure redirect URLs, render 404 responses
|
||||
with a view, send "no content" responses, etc.
|
||||
Some use cases are
|
||||
https://jira.spring.io/browse/SPR-11543?focusedCommentId=100308&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-100308[listed here].
|
||||
** Path matching customizations are frequently used and now built-in.
|
||||
See <<mvc-config-path-matching>>.
|
||||
* http://groovy-lang.org/docs/groovy-2.3.6/html/documentation/markup-template-engine.html[Groovy markup template]
|
||||
support (available in Groovy 2.3) -- If you've been waiting for DRY markup, along the
|
||||
lines of HAML (Ruby on Rails), this one is for you.
|
||||
support (based on Groovy 2.3). See the `GroovyMarkupConfigurer` and respecitve
|
||||
`ViewResolver` and `View' implementations.
|
||||
|
||||
=== WebSocket STOMP Messaging Improvements
|
||||
|
||||
* SockJS (Java) client-side support. See `SockJsClient` and classes in same package.
|
||||
* New application context events `SessionSubscribeEvent` and `SessionUnubscribeEvent` published
|
||||
when STOMP clients subscribe and unsubscribe.
|
||||
* New "websocket" scope. See <<websocket-stomp-websocket-scope>>.
|
||||
* `@SendToUser` can target only a single session and does not require an authenticated user.
|
||||
* `@MessageMapping` methods can use dot "." instead of slash "/" as path separator.
|
||||
See https://jira.spring.io/browse/SPR-11660[SPR-11660].
|
||||
* STOMP/WebSocket monitoring info collected and logged. See <<websocket-stomp-stats>>.
|
||||
* Significantly optimized and improved logging that should remain very readable
|
||||
and compact even at DEBUG level.
|
||||
* Optimized message creation including support for temporary message mutability
|
||||
and avoiding automatic message id and timestamp creation. See Javadoc of
|
||||
`MessageHeaderAccessor`.
|
||||
* STOMP/WebSocket connections that have not activity 60 seconds after the WebSocket
|
||||
session is established. See jira.springsource.org/browse/SPR-11884[SPR-11884].
|
||||
|
||||
=== Testing Improvements
|
||||
|
||||
|
@ -1122,7 +1142,7 @@ method has been added.
|
|||
* Various improvements to `MockServletContext`, `MockHttpServletRequest`, and other
|
||||
Servlet API mocks.
|
||||
* `AssertThrows` has been refactored to support `Throwable` instead of `Exception`.
|
||||
* JSON responses can be asserted with https://github.com/skyscreamer/JSONassert[JSON Assert]
|
||||
* In Spring MVC Test, JSON responses can be asserted with https://github.com/skyscreamer/JSONassert[JSON Assert]
|
||||
as an extra option to using JSONPath much like it has been possible to do for XML with
|
||||
XMLUnit.
|
||||
* `MockMvcBuilder` _recipes_ can now be created with the help of `MockMvcConfigurer`. This
|
||||
|
|
Loading…
Reference in New Issue