From aa6492ef8a76fd1345979918c238a6fc2921af33 Mon Sep 17 00:00:00 2001 From: Rainer Hermanns Date: Wed, 13 Sep 2006 11:35:29 +0000 Subject: [PATCH] URL Tag includeParams default attribute value should be configurable o backport from WW 2.2.4 Issue Number: WW-1442 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@442946 13f79535-47bb-0310-9956-ffa450edef68 --- core/src/main/java/org/apache/struts2/StrutsConstants.java | 5 ++++- core/src/main/java/org/apache/struts2/components/URL.java | 7 ++++++- .../main/resources/org/apache/struts2/default.properties | 2 ++ .../test/java/org/apache/struts2/config/SettingsTest.java | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java index 567d205aa..d28067e97 100644 --- a/core/src/main/java/org/apache/struts2/StrutsConstants.java +++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java @@ -47,7 +47,10 @@ public final class StrutsConstants { /** The HTTPS port used by Struts URLs */ public static final String STRUTS_URL_HTTPS_PORT = "struts.url.https.port"; - /** The com.opensymphony.xwork.ObjectFactory implementation class */ + /** The default includeParams method to generate Struts URLs */ + public static final String STRUTS_URL_INCLUDEPARAMS = "struts.url.includeParams"; + + /** The com.opensymphony.xwork.ObjectFactory implementation class */ public static final String STRUTS_OBJECTFACTORY = "struts.objectFactory"; /** The com.opensymphony.xwork.util.ObjectTypeDeterminer implementation class */ diff --git a/core/src/main/java/org/apache/struts2/components/URL.java b/core/src/main/java/org/apache/struts2/components/URL.java index 224c6ef7b..10b073788 100644 --- a/core/src/main/java/org/apache/struts2/components/URL.java +++ b/core/src/main/java/org/apache/struts2/components/URL.java @@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.StrutsException; +import org.apache.struts2.StrutsConstants; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.Dispatcher; import org.apache.struts2.portlet.context.PortletActionContext; import org.apache.struts2.portlet.util.PortletUrlHelper; @@ -153,7 +155,10 @@ public class URL extends Component { // this at start so body params can override any of these they wish. try { // ww-1266 - String includeParams = GET; + String includeParams = + Settings.isSet(StrutsConstants.STRUTS_URL_INCLUDEPARAMS) ? + Settings.get(StrutsConstants.STRUTS_URL_INCLUDEPARAMS).toLowerCase() : GET; + if (this.includeParams != null) { includeParams = findString(this.includeParams); diff --git a/core/src/main/resources/org/apache/struts2/default.properties b/core/src/main/resources/org/apache/struts2/default.properties index 99b692284..34bc06934 100644 --- a/core/src/main/resources/org/apache/struts2/default.properties +++ b/core/src/main/resources/org/apache/struts2/default.properties @@ -122,6 +122,8 @@ struts.configuration.xml.reload=false ### used to build URLs, such as the UrlTag struts.url.http.port = 80 struts.url.https.port = 443 +### possible values are: none, get or all +struts.url.includeParams = get ### Load custom default resource bundles # struts.custom.i18n.resources=testmessages,testmessages2 diff --git a/core/src/test/java/org/apache/struts2/config/SettingsTest.java b/core/src/test/java/org/apache/struts2/config/SettingsTest.java index 794d8146f..7abc6bc8b 100644 --- a/core/src/test/java/org/apache/struts2/config/SettingsTest.java +++ b/core/src/test/java/org/apache/struts2/config/SettingsTest.java @@ -33,6 +33,7 @@ import com.opensymphony.xwork2.util.LocalizedTextUtil; public class SettingsTest extends StrutsTestCase { public void testSettings() { + assertEquals("get", Settings.get(StrutsConstants.STRUTS_URL_INCLUDEPARAMS)); assertEquals("12345", Settings.get(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)); assertEquals("\temp", Settings.get(StrutsConstants.STRUTS_MULTIPART_SAVEDIR)); @@ -44,7 +45,7 @@ public class SettingsTest extends StrutsTestCase { assertEquals("de", locale.getLanguage()); int count = getKeyCount(); - assertEquals(30, count); + assertEquals(31, count); } public void testDefaultResourceBundlesLoaded() {