RedirectViews should always use RESPONSE_STATUS_ATTRIBUTE
By default, RedirectViews have http10Compatible set to true, which means that they use HTTP 302 as a default HTTP response status. Setting this property to false make RedirectViews use HTTP 303 by default. Now when set to false, RedirectViews also don't use the RESPONSE_STATUS_ATTRIBUTE request attribute as a response HTTP if it is available. This commit makes both configuration choices behave the same regarding this request attribute: use it as a response status if it's available. Issue: SPR-13208
This commit is contained in:
@@ -591,10 +591,15 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
|
||||
String encodedRedirectURL = response.encodeRedirectURL(targetUrl);
|
||||
if (http10Compatible) {
|
||||
HttpStatus attributeStatusCode = (HttpStatus) request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE);
|
||||
if (this.statusCode != null) {
|
||||
response.setStatus(this.statusCode.value());
|
||||
response.setHeader("Location", encodedRedirectURL);
|
||||
}
|
||||
else if (attributeStatusCode != null) {
|
||||
response.setStatus(attributeStatusCode.value());
|
||||
response.setHeader("Location", encodedRedirectURL);
|
||||
}
|
||||
else {
|
||||
// Send status code 302 by default.
|
||||
response.sendRedirect(encodedRedirectURL);
|
||||
|
||||
Reference in New Issue
Block a user