|
14 | 14 | */ |
15 | 15 | package org.codehaus.groovy.grails.web.pages; |
16 | 16 |
|
17 | | -import groovy.lang.*; |
| 17 | +import grails.util.GrailsUtil; |
| 18 | +import groovy.lang.GroovyClassLoader; |
18 | 19 | import groovy.text.Template; |
19 | | - |
20 | | -import java.io.*; |
21 | | -import java.net.URL; |
22 | | -import java.net.URLConnection; |
23 | | -import java.util.Collections; |
24 | | -import java.util.HashMap; |
25 | | -import java.util.Map; |
26 | | - |
27 | | -import javax.servlet.ServletContext; |
28 | | -import javax.servlet.http.HttpServletRequest; |
29 | | - |
| 20 | +import org.apache.commons.lang.StringUtils; |
30 | 21 | import org.apache.commons.logging.Log; |
31 | 22 | import org.apache.commons.logging.LogFactory; |
32 | | -import org.apache.commons.lang.StringUtils; |
33 | 23 | import org.codehaus.groovy.control.CompilationFailedException; |
| 24 | +import org.codehaus.groovy.grails.support.ResourceAwareTemplateEngine; |
| 25 | +import org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException; |
34 | 26 | import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes; |
35 | 27 | import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest; |
36 | | -import org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException; |
37 | | -import org.codehaus.groovy.grails.support.ResourceAwareTemplateEngine; |
| 28 | +import org.springframework.beans.BeansException; |
38 | 29 | import org.springframework.context.ApplicationContext; |
39 | 30 | import org.springframework.context.ApplicationContextAware; |
| 31 | +import org.springframework.core.io.*; |
| 32 | +import org.springframework.web.context.ServletContextAware; |
40 | 33 | import org.springframework.web.context.request.RequestContextHolder; |
41 | 34 | import org.springframework.web.context.support.ServletContextResourceLoader; |
42 | | -import org.springframework.web.context.ServletContextAware; |
43 | | -import org.springframework.core.io.*; |
44 | | -import org.springframework.beans.BeansException; |
45 | | -import grails.util.GrailsUtil; |
| 35 | + |
| 36 | +import javax.servlet.ServletContext; |
| 37 | +import javax.servlet.http.HttpServletRequest; |
| 38 | +import java.io.File; |
| 39 | +import java.io.FileNotFoundException; |
| 40 | +import java.io.IOException; |
| 41 | +import java.io.InputStream; |
| 42 | +import java.net.URL; |
| 43 | +import java.net.URLConnection; |
| 44 | +import java.util.Collections; |
| 45 | +import java.util.HashMap; |
| 46 | +import java.util.Map; |
46 | 47 |
|
47 | 48 | /** |
48 | 49 | * A GroovyPagesTemplateEngine based on (but not extending) the existing TemplateEngine implementations |
@@ -445,7 +446,8 @@ protected String establishPageName(Resource res, String pageName) { |
445 | 446 | name = pageName != null ? pageName : res.getURL().getPath(); |
446 | 447 | // As the name take the first / off and then replace all characters that aren't |
447 | 448 | // a word character or a digit with an underscore |
448 | | - name = name.substring(1).replaceAll("[^\\w\\d]", "_"); |
| 449 | + if(name.startsWith("/")) name = name.substring(1); |
| 450 | + name = name.replaceAll("[^\\w\\d]", "_"); |
449 | 451 |
|
450 | 452 | } catch (IllegalStateException e) { |
451 | 453 | name = generateTemplateName(); |
|
0 commit comments