diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java index 0a3f5893eff..4c7777c5b1a 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java @@ -22,7 +22,6 @@ import java.lang.reflect.Array; import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -38,6 +37,8 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.BeanUtils; import org.springframework.http.HttpStatus; import org.springframework.util.ObjectUtils; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.View; import org.springframework.web.util.UriTemplate; import org.springframework.web.util.UriUtils; @@ -47,8 +48,8 @@ import org.springframework.web.util.WebUtils; *
View that redirects to an absolute, context relative, or current request
* relative URL. The URL may be a URI template in which case the URI template
* variables will be replaced with values available in the model. By default
- * all primitive model attributes (or collections thereof), not used to fill
- * in URI tempate variables, are exposed as HTTP query parameters, but this
+ * all primitive model attributes (or collections thereof), not used as URI
+ * template variables, are exposed as HTTP query parameters, but this
* behavior can be changed by overriding the
* {@link #isEligibleProperty(String, Object)} method.
*
@@ -99,6 +100,7 @@ public class RedirectView extends AbstractUrlBasedView {
* Constructor for use as a bean.
*/
public RedirectView() {
+ setExposePathVariables(false);
}
/**
@@ -110,6 +112,7 @@ public class RedirectView extends AbstractUrlBasedView {
*/
public RedirectView(String url) {
super(url);
+ setExposePathVariables(false);
}
/**
@@ -121,6 +124,7 @@ public class RedirectView extends AbstractUrlBasedView {
public RedirectView(String url, boolean contextRelative) {
super(url);
this.contextRelative = contextRelative;
+ setExposePathVariables(false);
}
/**
@@ -134,6 +138,7 @@ public class RedirectView extends AbstractUrlBasedView {
super(url);
this.contextRelative = contextRelative;
this.http10Compatible = http10Compatible;
+ setExposePathVariables(false);
}
/**
@@ -150,6 +155,7 @@ public class RedirectView extends AbstractUrlBasedView {
this.contextRelative = contextRelative;
this.http10Compatible = http10Compatible;
this.exposeModelAttributes = exposeModelAttributes;
+ setExposePathVariables(false);
}
@@ -245,23 +251,32 @@ public class RedirectView extends AbstractUrlBasedView {
enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
}
- UriTemplate redirectUri = createUriTemplate(targetUrl, enc);
- if (redirectUri.getVariableNames().size() > 0) {
- targetUrl = new StringBuilder(redirectUri.expand(model).toString());
- model = removeKeys(model, redirectUri.getVariableNames());
+ UriTemplate uriTemplate = createUriTemplate(targetUrl, enc);
+ if (uriTemplate.getVariableNames().size() > 0) {
+ Map