You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2004/11/20 15:01:34 UTC

svn commit: r105965 - struts/core/trunk/src/share/org/apache/struts/taglib

Author: husted
Date: Sat Nov 20 06:01:34 2004
New Revision: 105965

Modified:
   struts/core/trunk/src/share/org/apache/struts/taglib/TagUtils.java
Log:
Apply #32283 "Two slashes created by TagUtils.getActionMappingURL for webapps in root contex" submitted by Jan Kaiser.

Modified: struts/core/trunk/src/share/org/apache/struts/taglib/TagUtils.java
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/taglib/TagUtils.java	(original)
+++ struts/core/trunk/src/share/org/apache/struts/taglib/TagUtils.java	Sat Nov 20 06:01:34 2004
@@ -762,7 +762,14 @@
     public String getActionMappingURL(String action, String module, PageContext pageContext, boolean contextRelative) {
 
         HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
-        StringBuffer value = new StringBuffer(request.getContextPath());
+
+        String contextPath = request.getContextPath();
+        StringBuffer value = new StringBuffer();
+        // Avoid setting two slashes at the beginning of an action:
+        //  the length of contextPath should be more than 1
+        //  in case of non-root context, otherwise length==1 (the slash)
+        if (contextPath.length() > 1) value.append(contextPath);
+
         ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(module, request, pageContext.getServletContext());
 
         if ((moduleConfig != null) && (!contextRelative)) {

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org