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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user