You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/07/28 21:11:17 UTC
[2/2] git commit: WW-4330 Adds support for parameters on absolute
URLs closes #10
WW-4330 Adds support for parameters on absolute URLs closes #10
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/73da38e9
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/73da38e9
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/73da38e9
Branch: refs/heads/develop
Commit: 73da38e9defa0fdf3b9bba957488d72f6e1fc8d0
Parents: fc6a2c8
Author: Lukasz Lenart <lu...@apache.org>
Authored: Mon Jul 28 21:11:03 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Mon Jul 28 21:11:03 2014 +0200
----------------------------------------------------------------------
.../dispatcher/ServletRedirectResult.java | 39 ++++++++++----------
.../dispatcher/ServletRedirectResultTest.java | 1 +
2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/73da38e9/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
index ae25463..b6cd282 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
@@ -196,33 +196,32 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) {
finalLocation = request.getContextPath() + finalLocation;
}
-
- ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
- if (resultConfig != null) {
- Map<String, String> resultConfigParams = resultConfig.getParams();
-
- List<String> prohibitedResultParams = getProhibitedResultParams();
- for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
- if (!prohibitedResultParams.contains(e.getKey())) {
- Collection<String> values = conditionalParseCollection(e.getValue(), invocation, suppressEmptyParameters);
- if (!suppressEmptyParameters || !values.isEmpty()) {
- requestParameters.put(e.getKey(), values);
- }
+ }
+ ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
+ if (resultConfig != null) {
+ Map<String, String> resultConfigParams = resultConfig.getParams();
+
+ List<String> prohibitedResultParams = getProhibitedResultParams();
+ for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
+ if (!prohibitedResultParams.contains(e.getKey())) {
+ Collection<String> values = conditionalParseCollection(e.getValue(), invocation, suppressEmptyParameters);
+ if (!suppressEmptyParameters || !values.isEmpty()) {
+ requestParameters.put(e.getKey(), values);
}
}
}
+ }
- StringBuilder tmpLocation = new StringBuilder(finalLocation);
- urlHelper.buildParametersString(requestParameters, tmpLocation, "&");
-
- // add the anchor
- if (anchor != null) {
- tmpLocation.append('#').append(anchor);
- }
+ StringBuilder tmpLocation = new StringBuilder(finalLocation);
+ urlHelper.buildParametersString(requestParameters, tmpLocation, "&");
- finalLocation = response.encodeRedirectURL(tmpLocation.toString());
+ // add the anchor
+ if (anchor != null) {
+ tmpLocation.append('#').append(anchor);
}
+ finalLocation = response.encodeRedirectURL(tmpLocation.toString());
+
if (LOG.isDebugEnabled()) {
LOG.debug("Redirecting to finalLocation " + finalLocation);
}
http://git-wip-us.apache.org/repos/asf/struts/blob/73da38e9/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java b/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
index 6a9e871..56cfe9d 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java
@@ -87,6 +87,7 @@ public class ServletRedirectResultTest extends StrutsInternalTestCase implements
public void testFullUrlRedirect() {
view.setLocation("http://localhost/bar/foo.jsp");
+ responseMock.expectAndReturn("encodeRedirectURL", C.args(C.eq("http://localhost/bar/foo.jsp")), "http://localhost/bar/foo.jsp");
responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo.jsp")));
try {