diff --git a/grails-web-common/src/main/groovy/grails/web/pages/GroovyPagesUriService.java b/grails-web-common/src/main/groovy/grails/web/pages/GroovyPagesUriService.java index 87e30b63fcc..2671c85f588 100644 --- a/grails-web-common/src/main/groovy/grails/web/pages/GroovyPagesUriService.java +++ b/grails-web-common/src/main/groovy/grails/web/pages/GroovyPagesUriService.java @@ -48,7 +48,7 @@ public interface GroovyPagesUriService { String getTemplateURI(String controllerName, String templateName, boolean includeExtension); - String getAbsoluteTemplateURI(String templateName); + String getAbsoluteTemplateURI(String templateName, boolean includeExtension); String getAbsoluteViewURI(String viewName); diff --git a/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java b/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java index 8cf2429cf00..9213ba205e8 100644 --- a/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java +++ b/grails-web-common/src/main/groovy/org/grails/web/pages/GroovyPagesUriSupport.java @@ -109,12 +109,13 @@ public String getTemplateURI(String controllerName, String templateName) { * Obtains the URI to a template using the controller name and template name * @param controllerName The controller name * @param templateName The template name + * @param includeExtension The flag to include the template extension * @return The template URI */ @Override public String getTemplateURI(String controllerName, String templateName, boolean includeExtension) { if (templateName.startsWith(SLASH_STR)) { - return getAbsoluteTemplateURI(templateName); + return getAbsoluteTemplateURI(templateName, includeExtension); } FastStringWriter buf = new FastStringWriter(); @@ -147,9 +148,10 @@ public String getTemplateURI(String controllerName, String templateName, boolean * Used to resolve template names that are not relative to a controller. * * @param templateName The template name normally beginning with / + * @param includeExtension The flag to include the template extension * @return The template URI */ - public String getAbsoluteTemplateURI(String templateName) { + public String getAbsoluteTemplateURI(String templateName, boolean includeExtension) { FastStringWriter buf = new FastStringWriter(); String tmp = templateName.substring(1,templateName.length()); if (tmp.indexOf(SLASH) > -1) { @@ -163,7 +165,10 @@ public String getAbsoluteTemplateURI(String templateName) { buf.append(SLASH_UNDR); buf.append(templateName.substring(1,templateName.length())); } - String uri = buf.append(EXTENSION).toString(); + if (includeExtension) { + buf.append(EXTENSION); + } + String uri = buf.toString(); buf.close(); return uri; } diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java b/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java index 09577985858..6c48adb92a5 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java @@ -254,7 +254,7 @@ public GroovyPageScriptSource findTemplateInBinding(Object controller, String pl if (controller == null) { GrailsWebRequest webRequest = GrailsWebRequest.lookup(); if (webRequest == null) { - return findPageInBinding(pluginName, uriService.getAbsoluteTemplateURI(templateName), binding); + return findPageInBinding(pluginName, uriService.getAbsoluteTemplateURI(templateName, true), binding); } return findPageInBinding(pluginName, uriService.getTemplateURI(webRequest.getControllerName(), templateName), binding); } @@ -285,7 +285,7 @@ public GroovyPageScriptSource findTemplateInBinding(Object controller, String pl public GroovyPageScriptSource findTemplateInBinding(String templateName, TemplateVariableBinding binding) { GrailsWebRequest webRequest = GrailsWebRequest.lookup(); if (webRequest == null) { - return findPageInBinding(uriService.getAbsoluteTemplateURI(templateName), binding); + return findPageInBinding(uriService.getAbsoluteTemplateURI(templateName, true), binding); } return findPageInBinding(uriService.getTemplateURI(webRequest.getControllerName(), templateName), binding); } @@ -301,7 +301,7 @@ public GroovyPageScriptSource findTemplateInBinding(String templateName, Templat public GroovyPageScriptSource findTemplateInBinding(String pluginName, String templateName, TemplateVariableBinding binding) { GrailsWebRequest webRequest = GrailsWebRequest.lookup(); if (webRequest == null) { - return findPageInBinding(pluginName, uriService.getAbsoluteTemplateURI(templateName), binding); + return findPageInBinding(pluginName, uriService.getAbsoluteTemplateURI(templateName, true), binding); } return findPageInBinding(pluginName, uriService.getTemplateURI(webRequest.getControllerName(), templateName), binding); } @@ -314,7 +314,7 @@ public GroovyPageScriptSource findTemplateInBinding(String pluginName, String te * @return The script source */ public GroovyPageScriptSource findTemplateByPath(String uri) { - return findPage(uriService.getAbsoluteTemplateURI(uri)); + return findPage(uriService.getAbsoluteTemplateURI(uri, true)); } protected String lookupRequestFormat() {