Commit Graph

667 Commits

Author SHA1 Message Date
Sebastien Deleuze
874859493b Deprecate JSONP and disable it by default in Jackson view
Issue: SPR-16798
2018-06-08 12:33:27 +02:00
Juergen Hoeller
193c289080 ResponseEntityExceptionHandler rethrows unknown exception (for further processing in DispatcherServlet's HandlerExceptionResolver chain)
Issue: SPR-16743

(cherry picked from commit 7b894fe)
2018-05-05 16:32:08 +02:00
Rossen Stoyanchev
3502f6fdc2 Validate contextPath in RedirectView
Issue: SPR-16752
2018-04-23 15:27:22 -04:00
Juergen Hoeller
ac19c696fe Revised reference example for linkable controller method signature
Issue: SPR-16710

(cherry picked from commit 7ee6130)
2018-04-12 21:37:39 +02:00
Juergen Hoeller
98536e1387 Proper exception for controller method return types that do not work with MvcUriComponentsBuilder (e.g. final classes)
Issue: SPR-16710
2018-04-11 16:50:38 +02:00
Rossen Stoyanchev
986d219391 Replaces rather than prepend contextPath
Issue: SPR-16650
2018-03-29 18:26:31 -04:00
Juergen Hoeller
bcda243f63 Polishing 2018-03-29 17:34:28 +02:00
Juergen Hoeller
6e1cac9145 AcceptHeaderLocaleResolver keeps language match among supported locales
Issue: SPR-16599
2018-03-28 01:21:36 +02:00
Rossen Stoyanchev
b9ebdaaf37 Backport clean duplicate separators in resource URLs
Issue: SPR-16616
2018-03-21 23:18:36 -04:00
Brian Clozel
6fa9539ae2 Don't implicitly check preconditions on PUT requests
Prior to this commit, the `HttpEntityMethodProcessor` would check HTTP
conditions on non-safe requests (i.e. not GET/HEAD). This would prevent
Controllers from returning `ResponseEntity` containing response headers
with updated values of `"Last-Modified"` or `ETag` once the resource has
been updated.

This commit avoids those checks for non GET/HEAD requests - this code
can still be leveraged from Controllers themselves using
`ServletWebRequest::checkNotModified` methods.

Issue: SPR-15780
(cherry picked from ed7684d2b2)
2018-03-08 20:10:25 +01:00
Brian Clozel
56fdda167e Guard against invalid paths in ResourceUrlProvider
This commit makes sure that no `StringIndexOutOfBoundsException` is
thrown when `getForRequestUrl` is called with a URL that's shorter than
the expected context path.

Issue: SPR-16526
(cherry picked from commit 6d26e61ac7)
2018-03-05 15:28:36 +01:00
Juergen Hoeller
caed04473e Consistent HttpMethod identity comparisons
(cherry picked from commit 0de36d2)
2018-02-18 22:28:37 +01:00
Juergen Hoeller
722cb36e01 Consistent Class array vs vararg declarations (and related polishing)
(cherry picked from commit 3b810f3)
2018-02-14 16:38:28 +01:00
Juergen Hoeller
5ba37762fe Consistent ControllerAdvice applicability against user-declared class
Issue: SPR-16496

(cherry picked from commit 46cbdff)
2018-02-14 16:38:21 +01:00
Juergen Hoeller
8fda96cadb AcceptHeaderLocaleResolver falls back to language-only match among its supported locales
Issue: SPR-16457

(cherry picked from commit 4dc9645)
2018-02-12 13:42:33 +01:00
Rossen Stoyanchev
2a309a031a Revise charset by location support for static resources 2017-11-17 12:55:11 -05:00
Juergen Hoeller
640c8ff693 Polishing 2017-11-14 12:31:01 +01:00
Rossen Stoyanchev
9470719cdb Support charset config by (static) resource location
This commit adds support for configuring static resource locations
with a charset to be applied to relative paths.
2017-11-09 14:51:49 -05:00
Rossen Stoyanchev
97bc2762e1 Handle errors via AsyncListener
This is a limited backport of commit #e0678b mainly providing the fix without
exposing the onError callbacks.

Issue: SPR-16058
2017-11-08 23:10:16 -05:00
Juergen Hoeller
b0ae8f6058 ModelAttributeMethodProcessor detects re-enabled binding declaration
Issue: SPR-16083

(cherry picked from commit bec1fc1)
2017-10-18 13:29:41 +02:00
Rossen Stoyanchev
b6ca8a9018 HandlerMappingIntrospector is a bean 2017-10-09 10:44:38 -04:00
Juergen Hoeller
40ba95f82e Consistent configurer access in WebMvcConfigurationSupport
Issue: SPR-16017
2017-09-27 19:00:51 +02:00
Juergen Hoeller
cc70fdcbeb Backport further refinements from the nullability efforts
Issue: SPR-15656
2017-09-27 15:20:17 +02:00
Juergen Hoeller
dedecb9daa HttpEntityMethodProcessor lets entity headers override existing headers (again)
Issue: SPR-15952

(cherry picked from commit 5bdcb89)
2017-09-26 23:58:49 +02:00
Martin Švorc
e0a7b074ed Use original query string of forwarded request
Prior to this commit, the AbstractFlashMapManager has used the
originating URI but the query string of the forwarded request. That
resulted to FlashMap not being matched even when both originating
URI and query string matched the FlashMap attributes. The originating
query string is now used to match the forwarded request.

Issue: SPR-15505
2017-05-19 17:07:17 -04:00
Juergen Hoeller
a9a1f783c5 Polishing 2017-04-13 15:59:15 +02:00
Juergen Hoeller
a3d199f4dd AcceptHeaderLocaleResolver returns default locale in case of no supported locale found
Issue: SPR-15426
(cherry picked from commit ea98ee8)
2017-04-13 15:54:46 +02:00
Brian Clozel
70bca99da8 VersionResourceResolver should delegate to the chain
Prior to this commit, the `VersionResourceResolver` implementation of
`resolveUrlPathInternal` would delegate to the resolver chain but would
never use the give result if the current request didn't match a
configured version strategy pattern.

This is a problem if the resolver supposed to resolve the resource path
is configured after a `VersionResourceResolver` in the resolver chain;
this means that other resolver never gets to participate in the result
of the chain.

Issue: SPR-15372
(cherry picked from commit fdd5031)
2017-03-24 14:27:29 +01:00
Juergen Hoeller
35e37f6b60 Polishing 2017-02-20 23:15:05 +01:00
Juergen Hoeller
f117b804a8 ServletRequestMethodArgumentResolver passes null references through (again)
Issue: SPR-15214
(cherry picked from commit fc11321)
2017-02-20 23:14:54 +01:00
Juergen Hoeller
0f71f58616 Polishing 2017-02-18 00:52:12 +01:00
Juergen Hoeller
b0ef80c3ff Polishing 2017-02-16 14:20:40 +01:00
Juergen Hoeller
c15d687bf0 Polishing
(cherry picked from commit acf511a)
2017-02-02 21:20:27 +01:00
Juergen Hoeller
28849e0987 Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
(cherry picked from commit 1b2dc36)
2017-01-31 10:28:46 +01:00
Juergen Hoeller
b97e7d53bc Revised CookieLocaleResolver parse exception handling
Issue: SPR-15182
(cherry picked from commit e8776f8)
2017-01-24 19:28:47 +01:00
Philippe Marschall
f7d126043b Remove use of Boolean constructors
Codacy warns us that there are several references to Boolean
constructors in the tests. Direct usage of the Boolean constructor is
discouraged and even deprecated in Java 9 [1]. Boolean constructor use
can easily be replaced with the constant instances.

This commit contains the following changes:

 - replace references to Boolean constructors with boolean constants in
   JSP tag tests
 - update the copyright year where necessary
 - BooleanComparatorTests is intentionally left unchanged as it should
   also work with the non-constant instances correctly

 [1] http://download.java.net/java/jdk9/docs/api/java/lang/Boolean.html#Boolean-boolean-

Issue: SPR-15076
2017-01-04 09:32:32 +01:00
Brian Clozel
e2d6e709c3 Normalize resource URL in ResourceServlet
Issue: SPR-14946
2016-12-21 10:21:28 +01:00
Juergen Hoeller
b5f2e56e38 Polishing 2016-12-19 01:51:57 +01:00
Juergen Hoeller
f3cc4ab09d @RequestBody supports java.util.Optional
Issue: SPR-15007
(cherry picked from commit eeb7ae5)
2016-12-19 01:03:18 +01:00
Brian Clozel
b59455b63c Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes
should be removed from the request path.

This commit fixes the public path resolution for paths like
`/resources/main.svg#icon-hamburgermenu`.

Issue: SPR-14928
2016-12-12 15:23:23 +01:00
Brian Clozel
1a6dc86fed Allow RedirectAttributes on ExceptionHandlers
Prior to this commit, `@ExceptionHandler` methods could not be injected
with `RedirectAttributes` arguments. This would make it impossible to
handle an error by redirecting to another view and add flashmap
attributes, to be included in the model when the next view is called.

Here is an example:

```
@ExceptionHandler(MyException.class)
public String handleException(MyException ex, RedirectAttributes
    redirectAttributes) {

  redirectAttributes.addFlashAttribute("errorMessage",
      "This is an error message");
  return "redirect:/";
}
```

This commit adds a new `RedirectAttributesMethodArgumentResolver`
instance in the list of pre-configured `HandlerMethodArgumentResolver`
in `ExceptionHandlerExceptionResolver`.

Issue: SPR-14651
Cherry-picked from: 17089d6
2016-12-12 09:09:35 +01:00
bedrin
e707c40e0b Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:51:05 -05:00
Brian Clozel
bc29fb5a09 Do not execute ResourceUrlEncodingFilter only once per request
In case the filter is also registered to the ERROR dispatcher, the
following happens:
* the filter is executed once for the regular execution
* the filter should be executed a second time when dispatched to error

Since the filter is a `OncePerRequestFilter`, the filter is only
executed once and won't be executed when handling the error.

This can lead to situations like spring-projects/spring-boot#7348

This commit makes this filter a simple `GenericFilterBean`.

Issue: SPR-14891
2016-11-24 10:03:08 +01:00
Juergen Hoeller
7e7504f5ea Polishing 2016-11-03 23:20:33 +01:00
Juergen Hoeller
05ff83f95a ResourceHttpRequestHandler initializes PathExtensionContentNegotiationStrategy in afterPropertiesSet
Issue: SPR-14851
(cherry picked from commit b7d3a96)
2016-10-31 11:43:57 +01:00
Rossen Stoyanchev
c062835702 Respect ModelAndView.status in @ExceptionHandler
Issue: SPR-14006
2016-10-24 16:36:44 +01:00
Sebastien Deleuze
6731e52280 Better encapsulation for CORS default permit configuration
This commit also improves CorsRegistration Javadoc.

Issue: SPR-14798
2016-10-20 17:06:12 +02:00
Brian Clozel
c98cdd4f4c Fix missing ETag/LastModified headers in responses
Prior to this commit, the `HttpEntityMethodProcessor` would avoid
writing ETag/Last-Modified response headers before calling
`ServletWebRequest` to process conditional requests. This was done to
avoid duplicate response header values due to headers being already
written to the underlying servlet response.

This is still necessary for GET/HEAD requests, since this is properly
handled by `ServletWebRequest` for those cases. But
`HttpEntityMethodProcessor` should not make that decision for
PUT/PATCH/POST responses since developers are adding response headers on
purpose and should be in control of the situation — whereas
`ServletWebRequest` does not write those headers in those cases.

Issue: SPR-14767
Cherry-picked from: ee17f5662
2016-10-04 13:54:02 +02:00
Juergen Hoeller
ca17edd5ac Revised checkResource implementation
Issue: SPR-14729
2016-09-18 21:04:37 +02:00
Sam Brannen
15d3e8c3e1 Introduce 'value' alias for @Bean's 'name' attribute
In order to simplify configuration for use cases involving @Bean where
only a bean name or aliases are supplied as an attribute, this commit
introduces a new 'value' attribute that is an @AliasFor 'name' in @Bean.

Issue: SPR-14728
(cherry picked from commit 8f62b63)
2016-09-18 21:04:25 +02:00