mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
WW-5463 Exposes final location as request attribute FORWARD_SERVLET_PATH
This commit is contained in:
@@ -158,6 +158,13 @@ public class ServletDispatcherResult extends StrutsResultSupport {
|
||||
//if we are inside an action tag, we always need to do an include
|
||||
boolean insideActionTag = (Boolean) ObjectUtils.defaultIfNull(request.getAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION), Boolean.FALSE);
|
||||
|
||||
// this should allow integration with third-party view related frameworks
|
||||
if (finalLocation.contains("?")) {
|
||||
request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, finalLocation.substring(0, finalLocation.indexOf('?')));
|
||||
} else {
|
||||
request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, finalLocation);
|
||||
}
|
||||
|
||||
// If we're included, then include the view
|
||||
// Otherwise do forward
|
||||
// This allow the page to, for example, set content type
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.result;
|
||||
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
import org.apache.struts2.StrutsStatics;
|
||||
@@ -47,6 +48,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
|
||||
view.execute(invocation);
|
||||
|
||||
assertEquals("foo.jsp", response.getForwardedUrl());
|
||||
assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
|
||||
}
|
||||
|
||||
public void testInclude() throws Exception {
|
||||
@@ -60,6 +62,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
|
||||
view.execute(invocation);
|
||||
|
||||
assertEquals("foo.jsp", response.getIncludedUrl());
|
||||
assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
|
||||
}
|
||||
|
||||
public void testWithParameter() throws Exception {
|
||||
@@ -73,6 +76,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
|
||||
|
||||
// See https://issues.apache.org/jira/browse/WW-5486
|
||||
assertEquals("1", stack.findString("#parameters.bar"));
|
||||
assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user