Add propagateQueryParams property to RedirectView

This change makes it possible to configure RedirectView such that the
query string of the current request is added to the target URL.

This change is preparation for SPR-11543.
This commit is contained in:
Rossen Stoyanchev
2014-07-17 18:04:43 -04:00
parent 0e2c5ee96c
commit 0bbb7704b5
2 changed files with 73 additions and 4 deletions

View File

@@ -325,6 +325,19 @@ public class RedirectViewTests {
doTest(model, url, false, expectedUrlForEncoding);
}
@Test
public void propagateQueryParams() throws Exception {
RedirectView rv = new RedirectView();
rv.setPropagateQueryParams(true);
rv.setUrl("http://url.somewhere.com?foo=bar#bazz");
MockHttpServletRequest request = createRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setQueryString("a=b&c=d");
rv.render(new HashMap<String, Object>(), request, response);
assertEquals(302, response.getStatus());
assertEquals("http://url.somewhere.com?foo=bar&a=b&c=d#bazz", response.getHeader("Location"));
}
private void doTest(Map<String, ?> map, String url, boolean contextRelative, String expectedUrlForEncoding)
throws Exception {
doTest(map, url, contextRelative, true, expectedUrlForEncoding);