Commit Graph

1043 Commits

Author SHA1 Message Date
Juergen Hoeller 5682950289 Polishing 2016-05-06 12:03:10 +02:00
Juergen Hoeller 42d32ba396 ResourceRegion fits better in core.io.support (next to EncodedResource)
Issue: SPR-14221
2016-05-06 12:02:51 +02:00
Juergen Hoeller e5dbe12e85 ResourceHttpRequestHandler sets "Accept-Ranges" header only once
Issue: SPR-14221
2016-05-06 11:50:47 +02:00
Sam Brannen 7b13311f03 Delete unused imports 2016-05-03 20:12:37 +02:00
Brian Clozel 5ac31fb39d Refactor HTTP Range support with ResourceRegion
Prior to this commit, the `ResourceHttpMessageConverter` would support
all HTTP Range requests and `MethodProcessors` would "wrap" controller
handler return values with a `HttpRangeResource` to support that use
case in Controllers.

This commit refactors that support in several ways:
* a new ResourceRegion class has been introduced
* a new, separate, ResourceRegionHttpMessageConverter handles the HTTP
range use cases when serving static resources with the
ResourceHttpRequestHandler
* the support of HTTP range requests on Controller handlers has been
removed until a better solution is found

Issue: SPR-14221, SPR-13834
2016-05-02 19:00:52 +02:00
Brian Clozel 977840884b Allow custom instances of WebJarAssetLocator
This commit allows to configure a custom WebJarAssetLocator in
WebJarResourceResolvers.

Issue: SPR-14092
2016-04-28 19:02:04 +02:00
Sebastien Deleuze 15138ed96f Revisit ScriptTemplateView resource loading
Resources are now retrieved using the application context in order to
support natively non-classpath locations like /WEB-INF/...

As a consequence of this refactoring, ScriptTemplateView#createClassLoader()
protected method as been removed, since it did not make sense anymore with
this new resource loading implementation.

Issue: SPR-14210
2016-04-28 15:40:14 +02:00
Juergen Hoeller d06188ed4d ResponseEntity allows for setting non-standard status code
Issue: SPR-14205
2016-04-26 23:06:10 +02:00
Rossen Stoyanchev 5ec6206e3f Update spring-mvc-3.2.xsd
The backport in commit cf39078 changed the spring-mvc-3.2.xsd.
This change updates the same in the master branch.

Issue: SPR-14186
2016-04-21 14:11:49 -04:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Rossen Stoyanchev 7cdcc102a9 Explicit HEAD sorted higher than implicit GET match
Issue: SPR-14182
2016-04-17 15:12:43 -04:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Juergen Hoeller 4ae065996b Polishing
(cherry picked from commit aa5c12c)
2016-04-08 23:06:25 +02:00
Juergen Hoeller 37bd51cf6d Handle Resources beyond int length through Servlet 3.1's setContentLengthLong
Issue: SPR-14135
2016-04-08 15:54:24 +02:00
Juergen Hoeller ed14ae60e5 Consistent deprecation of outdated MVC infrastructure classes
Issue: SPR-14128
2016-04-07 11:37:34 +02:00
Juergen Hoeller f6cb30b165 @ExceptionHandler is able to process Error thrown from handler method
Issue: SPR-11106
2016-03-31 11:52:36 +02:00
Juergen Hoeller 2dae4d8134 Deprecated FormTag's "commandName" in favor of "modelAttribute"
Issue: SPR-14094
2016-03-29 12:09:16 +02:00
Juergen Hoeller 94cb7786c8 Polishing 2016-03-25 23:28:45 +01:00
Juergen Hoeller 775bcccd10 Polishing 2016-03-24 21:44:16 +01:00
Juergen Hoeller 852212d0c5 Polishing 2016-03-24 19:57:54 +01:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 06db5aa43f Polishing 2016-03-24 15:34:17 +01:00
Juergen Hoeller 9a52c81443 UriComponentsBuilder allows more efficient (and less restrictive) CORS origin comparison
Also introduces a specifically narrowed cloneBuilder() method for UriComponentsBuilders.

Issue: SPR-14080
2016-03-24 15:33:44 +01:00
Juergen Hoeller 3eff478c45 RequestMethodsRequestCondition uses common HttpMethod resolution
Issue: SPR-13776
2016-03-24 13:54:00 +01:00
Juergen Hoeller 86d5c5c0f7 Avoid putIfAbsent call in HttpEntityMethodProcessor
Issue: SPR-14086
2016-03-24 13:51:48 +01:00
Brian Clozel 20bb25647f Polish 2016-03-24 10:56:46 +01:00
Juergen Hoeller 5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Juergen Hoeller 311d4c95a3 Revised newline handling tests pass on Windows now
Issue: SPR-13503
2016-03-23 18:35:26 +01:00
Brian Clozel e079a726f8 Polish 2016-03-23 16:40:12 +01:00
Brian Clozel c7bd3b8440 Support HTTP range requests in Controllers
Prior to this commit, HTTP Range requests were only supported by the
ResourceHttpRequestHandler when serving static resources.

This commit improves the ResourceHttpMessageConverter that
now supports partial writes of Resources.
For this, the `HttpEntityMethodProcessor` and
`RequestResponseBodyMethodProcessor` now wrap resources with HTTP
range information in a `HttpRangeResource`, if necessary. The
message converter handle those types and knows how to handle partial
writes.

Controller methods can now handle Range requests for
return types that extend Resource or HttpEntity:

    @RequestMapping("/example/video.mp4")
    public Resource handler() { }

    @RequestMapping("/example/video.mp4")
    public HttpEntity<Resource> handler() { }

Issue: SPR-13834
2016-03-23 16:40:12 +01:00
Brian Clozel 15fe8279e6 Reset Expires HTTP header when caching configured
Just like SPR-13252 addressed this issue for the "Pragma" header, this
issue resets the HTTP 1.0 "Expires" header.
When such a header has been set (by a filter, for example) and HTTP
caching has been configured at the WebContentGenerator, this header
value is reset to "". In this case, "Cache-Control" and "Expires" might
have inconsistent values and we consider that the HTTP caching
configuration should take precedence.

Depending on the servlet container chosen to deploy the application,
this might result in empty "" header values or no header set at all.

Issue: SPR-14053
2016-03-23 16:35:13 +01:00
Kazuki Shimizu 9b2023111d Add newline at the beginning of textarea macro for FreeMarker and Velocity
Issue: SPR-13503
2016-03-23 11:31:16 +01:00
Rossen Stoyanchev 7a5e93ff16 Add support for setting the "Vary" response header
Issue: SPR-14070
2016-03-22 21:47:55 -04:00
Rossen Stoyanchev 6bfe0c050d Polish 2016-03-22 20:59:16 -04:00
Rossen Stoyanchev 92dd4eb3ef Fix NPE in ResponseBodyEmitterReturnValueHandler
The possibility of NPE was introduced in the previous commit:
971ccab038

Issue: SPR-14046
2016-03-16 13:40:35 -04:00
Rossen Stoyanchev 582864802e Ensure RedirectModel is initialized
This commit fixes an old bug in ModelAndViewContainer where getModel
returns a new ModelMap instance that isn't saved and re-used.

Issue: SPR-14045
2016-03-14 23:00:19 -04:00
Rossen Stoyanchev 971ccab038 DeferredResult/ResponseBodyEmitter adapter mechanism
The DeferredResult~ and the ResponseBodyEmitterReturnValueHandler now
each expose an adapter mechanism for plugging in other async return
value types. As a result the ListenableFutureReturnValueHandler and
CompletionStageReturnValueHandler are no longer needed and are now
deprecated.

Issue: SPR-14046
2016-03-14 12:20:02 -04:00
Juergen Hoeller d124a13eb4 Consistent use of empty enumerations 2016-03-11 15:07:59 +01:00
Juergen Hoeller 8852a5e178 Support for placeholders in @CrossOrigin attributes
Issue: SPR-14010
2016-03-11 15:04:16 +01:00
Brian Clozel 8ca6a18dae Allow Validator config in XML websocket namespace
This commit adds a new "validator" XML attribute to the
`<websocket:message-broker/>` element. This allows configuring a
specific Validator to be used for payload validation.

Issue: SPR-13996
2016-03-10 16:35:20 +01:00
Brian Clozel 0a56667093 Fix SpringUrl Velocity macro URI encoding
Prior to this commit, the springUrl Velocity macro would only prepend
the context to the given URL; this means that the
ServletHttpResponse.encodeUri method is not called and neither the
ResourceUrlProvider.

This commit changes this macro to use RequestContext.getContextUrl which
prepends the context and encodes the URI.

Issue: SPR-14027
2016-03-08 17:07:59 +01:00
Rossen Stoyanchev ff2a911baa Update MVC config to use CNM for static resources
The MVC config now plugs the configured ContentNegotiationManager into
resource request handling.

Issue: SPR-13658
2016-03-04 16:06:01 -05:00
Rossen Stoyanchev f162256906 Use ContentNegotiationManager for static resources
The ResourceHttpRequestHandler now relies on the conifgured
ContentNegotiationManager to determine the content type for resource
requests rather than implementing that internally.

First we check against the matched resource based on the resource file
extension. Then we expand the check against the request with any
configured content negotiation strategy.

Issue: SPR-13658
2016-03-04 16:06:01 -05:00
Rossen Stoyanchev 1a76f7e9c2 Polish static resource handling 2016-03-04 16:05:49 -05:00
Brian Clozel 5067f00228 Polish
Issue: SPR-14018
2016-03-04 11:38:25 +01:00
Ruben Dijkstra 41da04d386 Remove duplicate slash from resolved WebJar locations
This commit updates the WEBJARS_LOCATION in WebJarResourceResolver to
avoid getting duplicate slashes in resolved resources locations such
as `/webjars//bootstrap/3.3.2/js/bootstrap.min.js`.

Issue: SPR-14018
2016-03-04 11:36:30 +01:00
Brian Clozel 44c32128dc Add newline at the beginning of textarea JSP tags
This commit adds a newline char at the beginning of textarea tags
values. As per the HTML 4.01 spec (and browsers behavior), a line break
following a start tag is ignored.

This can lead to Spring's textarea tag to ignore a line break char at
the beginning of a tag value.

See https://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks

Issue: SPR-13503
2016-03-03 16:48:17 +01:00
Brian Clozel 50bcd67fb6 Relax SPR-13867 changes for ResourceHttpRequestHandler
Prior to this change, SPR-13867 made sure that any class extending
WebContentGenerator would not overwrite existing HTTP "Cache-Control"
response headers - set by a filter, a Controller handler, etc.

This caused issues with resource handling, since specifying a cache
configuration there would not overwrite default headers set by filters,
for example by Spring Security.

This commit restricts the previous changes to the
RequestMappingHandlerAdapter, in order to avoid overwriting header set
by a filter or a Controller handler in those cases.

Issue: SPR-14005
2016-03-02 17:42:44 +01:00
Brian Clozel 3df66d023c Polish documentation on WebApplicationInitializer
Issue: SPR-13978
2016-03-01 17:38:52 +01:00
Sebastien Deleuze c385427397 Allow to specify AbstractHttpMessageConverter default charset
Before this commit, specifying the charset to use with produces or
consumes @RequestMapping attributes resulted in default charset
loss. That was really annoying for JSON for example, where using
UTF-8 charset is mandatory in a lot of use cases.

This commit adds a defaultCharset property to
AbstractHttpMessageConverter in order to avoid losing the
default charset when specifying the charset with these
@RequestMapping attributes.

It changes slightly the default behavior (that's why we have waited
4.3), but it is much more error prone, and will match with most
user's expectations since the charset loss was accidental in most
use cases (users usually just want to limit the media type supported
by a specific handler method).

Issue: SPR-13631
2016-02-29 23:34:32 +01:00
Sam Brannen 467b5f3f28 Introduce composed annotations for @RequestMapping
This commit introduces the following common composed annotations for
@RequestMapping in Spring MVC and Spring MVC REST.

- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping

Issue: SPR-13992
2016-02-29 18:22:30 +01:00
Juergen Hoeller a02fd7c995 RequestMappingHandlerAdapter properly invokes handler method in case of no session as well
Issue: SPR-13999
2016-02-29 15:05:50 +01:00
Juergen Hoeller 9c0f99c0b5 Polishing 2016-02-29 12:57:09 +01:00
Juergen Hoeller 1815a6a7eb RequestMappingHandlerAdapter properly invokes handler method in synchronizeOnSession mode again
Issue: SPR-13999
2016-02-29 11:12:11 +01:00
Juergen Hoeller ca19920d74 Refined ApplicationContextInitializer assignability exception 2016-02-24 17:50:14 +01:00
Rossen Stoyanchev b3d67b928b Check supported locales in AcceptHeaderLocaleResolver
Issue: SPR-13330
2016-02-22 09:44:06 -05:00
Rossen Stoyanchev f32aded27a Consolidate CORS/OPTIONS request mapping
The CORS pre-flight request matching logic for all request conditions
was added (in 4.2) to RequestMappingInfo. However the logic for
default handling of all HTTP OPTIONS requests for 4.3 unintentionally
overrode some of the pre-flight request handling thus causing issues.

This commit moves CORS pre-flight matching logic into each respective
RequestMethodCondition implementations so each has to consider in one
place what happens for pre-flight and for all other requests.

Issue: SPR-13130
2016-02-19 13:56:52 -05:00
Rossen Stoyanchev 26575148a5 Polish test class 2016-02-19 13:56:52 -05:00
Rossen Stoyanchev 08eb623c41 Fix regression introduced in 4.3 snapshot
Commit ccd17d introduced a regression where a custom HTTP method
would no longer match for an empty @RequestMapping condition.

The previous behavior should now be restored. Effectively
RequestMethodRequestCondition as before will now match to any HTTP
method (even unknown/custom ones) if the methods condition is empty.
The only exception is HTTP OPTIONS for which we provide default
handling as a fallback (i.e. when not mapped explicitly).

Issue: SPR-13130
2016-02-18 14:37:36 -05:00
Sam Brannen c2f704717e Polish Javadoc for DefaultRequestToViewNameTranslator 2016-02-17 17:30:57 +00:00
Rossen Stoyanchev 024bd6e604 Polish 2016-02-17 08:23:18 -05:00
matthew-pearson 57b466fdfc 404 rather than 405 or 200
Check that the path is valid and resolvable before checking that the
http method is supported. For invalid or unresolvable paths, always
respond with a 404.
2016-02-17 08:23:18 -05:00
Juergen Hoeller f6ebc4ce97 Polishing 2016-02-11 22:24:50 +01:00
Rossen Stoyanchev a1e9e6f53e Polish MVC Java config tests 2016-02-10 15:29:56 -05:00
Rossen Stoyanchev d53c04b4df Add option to extend exception resolvers
Issue: SPR-13931
2016-02-10 15:26:40 -05:00
Rossen Stoyanchev c45ad3022b Add "hosts" property to RedirectView
Issue: SPR-13693
2016-02-10 14:21:27 -05:00
Rossen Stoyanchev aba04d576f Polish RedirectViewTests 2016-02-10 14:21:27 -05:00
Brian Clozel 0ab3f6092c Fix failing tests
Issue: SPR-13913
2016-02-10 13:48:49 +01:00
Rossen Stoyanchev cdfcc23b6f Reduce log level for @ExceptionHandler failure
Issue: SPR-13932
2016-02-09 12:57:02 -05:00
Rossen Stoyanchev e4539d9f40 Add protected method for required RequestBody 2016-02-05 02:24:03 -05:00
Rossen Stoyanchev 7756feacd8 Polish 2016-02-05 00:04:59 -05:00
Rossen Stoyanchev 1291d6e1bd Support CharSequence for response body
Issue: SPR-13423
2016-02-04 23:55:48 -05:00
Juergen Hoeller 28e8af2e2e AbstractXlsView does not explicitly flush (for compatibility with WebSphere Liberty)
Issue: SPR-13910
2016-02-04 19:48:05 +01:00
Rossen Stoyanchev aa064d7653 Polish MVC config tests 2016-01-29 14:58:32 -05:00
Rossen Stoyanchev 1cf0fb8174 Shared custom argument resolvers
Custom argument resolvers configured in the MVC Java config or the
MVC namespace are now injected in both the RequestMappingHandlerAdapter
as well as in the ExceptionHandlerExceptionResolver.

Issue: SPR-12058
2016-01-29 14:49:25 -05:00
Rossen Stoyanchev e62ada898b Add @RequestAttribute with servlet-based support
Issue: SPR-13894
2016-01-26 16:37:50 -05:00
Rossen Stoyanchev 698f923fc3 Add @SessionAttribute with Servlet-based support
Issue: SPR-13894
2016-01-26 16:37:44 -05:00
Juergen Hoeller 7df3a327f6 Polishing 2016-01-26 22:29:48 +01:00
Juergen Hoeller 3779fe9bf6 @UsesJava8 declaration on inner class
Issue: SPR-13850
2016-01-26 18:18:27 +01:00
Juergen Hoeller b4f33adf48 Consistent java.util.Optional resolution, lenient handling of optional multipart files, correct Servlet 3.0 Part list/array selection
Issue: SPR-13418
Issue: SPR-13849
Issue: SPR-13850
Issue: SPR-13893
2016-01-26 18:06:15 +01:00
Rossen Stoyanchev 2607a22537 HTTP OPTIONS lists all HTTP methods except TRACE
This is in line with the current behavior of HttpServlet that would
have been in used with dispatchOptionsRequest on the DispatcherSerlvet
set to false (the default prior to 4.3).

Issue: SPR-13130
2016-01-25 16:35:23 -05:00
Rossen Stoyanchev 319e8e2c2f Add allowHeader property to WebContentGenerator
The WebContentGenerator now maintains an additional property that
sub-classes can use for an "Allow" header in response to an HTTP
OPTIONS request. This property is pre-initialized once at startup
and does not have to rely on getSupportedMethods in addition to
adding HTTP OPTIONS if not explicitly listed.

Issue: SPR-13130
2016-01-25 16:35:15 -05:00
Rossen Stoyanchev 135738f9bf AbstractController supports HTTP OPTIONS
Issue: SPR-13130
2016-01-25 08:49:04 -05:00
Rossen Stoyanchev ccd17dfaea Support HTTP OPTIONS
Issue: SPR-13130
2016-01-24 20:18:41 -05:00
Rossen Stoyanchev d70ad765bf Support HTTP HEAD
Issue: SPR-13130
2016-01-24 20:18:41 -05:00
Rossen Stoyanchev fb7dfc4569 Polish 2016-01-24 20:18:35 -05:00
Brian Clozel 2b3ad218e5 Clarify RequestMappingHandlerAdapter javadoc
This commit updates the javadoc of
`RequestMappingHanderAdapter.setCacheSecondsForSessionAttributeHandlers`
to explain how one can disable that feature and prevent "Cache-Control"
directives from being added when `@SessionAttributes` annotations are
used on Controllers.

Issue: SPR-13598
2016-01-22 21:17:58 +01:00
Brian Clozel 84fe46cd43 Register prefixed path patterns with FixedVersionStrategy
Prior to this change, configuring a `FixedVersionStrategy` like so
would configure a single "/js/**" path pattern:

```
versionResourceResolver.addFixedVersionStrategy("v1.0.0","/js/**");
```

This commit makes sure that for each path pattern, its prefixed version
is added to the map. For example, the previous configuration also
adds "/v1.0.0/js/**".

Issue: SPR-13883
2016-01-22 18:30:39 +01:00
Brian Clozel 8f1d06f19c Reorder HTTP headers processing in RequestMappingHandlerAdapter
Prior to this change, the `RequestMappingHandlerAdapter` would first add
a "Cache-Control" HTTP header to the response (depending on its
`WebContentGenerator` configuration and `@SessionAttributes` on the
handler class); then, the Adapter would delegate the actual handler the
processing of the request.
This leads to issues, as the handler does not have full control to the
response and has to deal with pre-existing headers in the response. This
means that the Adapter and the handler can add incompatible
Cache-Control directives without knowing it, since one cannot see the
headers added by the other until the response is committed.

This commit switches the order of execution: first, the handler is
called (possibly adding HTTP headers), then the RMHA processes the
response and adds "Cache-Control" directives *only if there's no
Cache-Control header already defined*.

Issue: SPR-13867
2016-01-22 16:04:03 +01:00
Rossen Stoyanchev ebccfd023a MVC Java config protected factory methods
This change exposes protected methods for instantiating sub-classes of
RequestMappingHandlerAdapter and ExceptonHandlerExceptionResolver
similar to the existing method for RequestMappingHandlerMapping.
2016-01-22 09:48:50 -05:00
Brian Clozel 2f6d86b7aa Fix OutOfBoundsExceptio in ResourceUrlEncodingFilter
Prior to this change, the `ResourceUrlEncodingFilter` would try to
lookup resources URLs as soon as the given URL would be longer than the
expected context+servlet prefix path. This can lead to
OutOfBoundsExceptions when the provided URL does not start with that
prefix and still has the required length.

This commit makes sure that all candidate URLs for resources lookup are
prefixed with the cached servlet and context path. This underlines the
fact that the `ResourceUrlEncodingFilter` does not support relative URLs
for now and delegates to the native servlet implementation in that case.

Issue: SPR-13861
2016-01-21 17:28:29 +01:00
Rossen Stoyanchev 9e16cbda4c Polish ServletServerHttpRequest change 2016-01-20 17:50:36 -05:00
Sammy Chu 5185953f29 Avoid double encoding URI in ServletServerHttpRequest
Issue: SPR-13876
2016-01-20 17:42:40 -05:00
Rossen Stoyanchev a5f4aa6824 Add HttpStatus to ModelAndView
Issue: SPR-13560
2016-01-20 16:54:05 -05:00
Rossen Stoyanchev 73a794336c Support @ResponseStatus on controller type level
Issue: SPR-13547
2016-01-15 17:15:34 -05:00
Juergen Hoeller 9761af9ad8 Validate @RequestMapping methods on AOP proxies
Issue: SPR-13842
2016-01-15 17:01:58 +01:00
Stephane Nicoll 2fc2c29e9a Update copyright header 2016-01-15 10:51:11 +01:00
Rossen Stoyanchev 24fdf64d91 Fix javadoc issue in ResponseEntityExceptionHandler
Issue: SPR-13869
2016-01-14 14:25:30 -05:00
Juergen Hoeller 773d175681 Polishing 2016-01-13 12:52:05 +01:00
Brian Clozel cdda839426 XML configuration support for RFC 5861
This commit adds the XML+XSD configuration part of the RFC 5861
Cache-Control directives added in Spring's `CacheControl`.

Issue: SPR-13841
2016-01-07 18:13:34 +01:00