You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2013/05/28 06:22:35 UTC
svn commit: r1486735 - in /myfaces/core/branches/2.0.x:
impl/src/main/java/org/apache/myfaces/application/
impl/src/main/java/org/apache/myfaces/application/jsp/
shared/src/main/java/org/apache/myfaces/shared/application/
Author: lu4242
Date: Tue May 28 04:22:34 2013
New Revision: 1486735
URL: http://svn.apache.org/r1486735
Log:
MYFACES-3726 root context induces wrong urls
Modified:
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/jsp/JspViewHandlerImpl.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java?rev=1486735&r1=1486734&r2=1486735&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/ViewHandlerImpl.java Tue May 28 04:22:34 2013
@@ -244,9 +244,22 @@ public class ViewHandlerImpl extends Vie
{
if (path.length() > 0 && path.charAt(0) == '/')
{
- return facesContext.getExternalContext().getRequestContextPath() + path;
+ String contextPath = facesContext.getExternalContext().getRequestContextPath();
+ if (contextPath == null)
+ {
+ return path;
+ }
+ else if (contextPath.length() == 1 && contextPath.charAt(0) == '/')
+ {
+ // If the context path is root, it is not necessary to append it, otherwise
+ // and extra '/' will be set.
+ return path;
+ }
+ else
+ {
+ return contextPath + path;
+ }
}
-
return path;
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/jsp/JspViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/jsp/JspViewHandlerImpl.java?rev=1486735&r1=1486734&r2=1486735&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/jsp/JspViewHandlerImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/jsp/JspViewHandlerImpl.java Tue May 28 04:22:34 2013
@@ -294,7 +294,21 @@ public class JspViewHandlerImpl extends
{
if (path.length() > 0 && path.charAt(0) == '/')
{
- return facesContext.getExternalContext().getRequestContextPath() + path;
+ String contextPath = facesContext.getExternalContext().getRequestContextPath();
+ if (contextPath == null)
+ {
+ return path;
+ }
+ else if (contextPath.length() == 1 && contextPath.charAt(0) == '/')
+ {
+ // If the context path is root, it is not necessary to append it, otherwise
+ // and extra '/' will be set.
+ return path;
+ }
+ else
+ {
+ return contextPath + path;
+ }
}
return path;
@@ -676,4 +690,4 @@ public class JspViewHandlerImpl extends
}
}
}
-}
\ No newline at end of file
+}
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java?rev=1486735&r1=1486734&r2=1486735&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java Tue May 28 04:22:34 2013
@@ -197,7 +197,12 @@ public class DefaultViewHandlerSupport i
String contextPath = externalContext.getRequestContextPath();
//StringBuilder builder = new StringBuilder(contextPath);
StringBuilder builder = SharedStringBuilder.get(context, VIEW_HANDLER_SUPPORT_SB);
- builder.append(contextPath);
+ // If the context path is root, it is not necessary to append it, otherwise
+ // and extra '/' will be set.
+ if (contextPath != null && !(contextPath.length() == 1 && contextPath.charAt(0) == '/') )
+ {
+ builder.append(contextPath);
+ }
if (mapping != null)
{
if (mapping.isExtensionMapping())