From 55db4ae94b22c448566190f6fdfdc36f60819105 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 24 Sep 2015 18:43:51 +0200 Subject: [PATCH] Document that @ResponseStatus overrides redirect views Issue: SPR-13439 --- .../springframework/web/bind/annotation/ResponseStatus.java | 3 ++- src/asciidoc/web-mvc.adoc | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/ResponseStatus.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/ResponseStatus.java index fb05449788..8ad9c1e9b5 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/ResponseStatus.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/ResponseStatus.java @@ -30,7 +30,8 @@ import org.springframework.http.HttpStatus; * {@link #reason} that should be returned. * *

The status code is applied to the HTTP response when the handler - * method is invoked. + * method is invoked and overrides status information set by other means, + * like {@code ResponseEntity} or {@code "redirect:"}. * *

Warning: when using this annotation on an exception * class, or when setting the {@code reason} attribute of this annotation, diff --git a/src/asciidoc/web-mvc.adoc b/src/asciidoc/web-mvc.adoc index d38325fe30..363eea6393 100644 --- a/src/asciidoc/web-mvc.adoc +++ b/src/asciidoc/web-mvc.adoc @@ -2789,6 +2789,9 @@ name such as `redirect:/myapp/some/resource` will redirect relative to the curre Servlet context, while a name such as `redirect:http://myhost.com/some/arbitrary/path` will redirect to an absolute URL. +Note that the controller handler is annotated with the `@ResponseStatus`, the annotation +value takes precedence over the response status set by `RedirectView`. + [[mvc-redirecting-forward-prefix]] ==== The forward: prefix