Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2.2, 1.3 RC2
-
Component/s: View technologies
-
Labels:None
-
Environment:Grails 1.2.2, Spring MVC Plugin 0.1, Freemarker Plugin 0.2.
Description
Mapping a url to a view name like this normally works fine:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(view:"/index")
"500"(view:'/error')
}
}
The "/" pattern is mapped to the "/index" view and the default view resolver will associate that with grails-app/views/index.gsp. If there are multiple view resolvers in the application context Grails currently only tries one of them. This is the case when certain plugins are installed. For example, both the springmvc and freemarker plugins contribute a view resolver to the application context.
The simplest way to recreate the problem is to create a new app and install the springmvc plugin into the app. Start the app and try to access the application root and the view resolution should fail.
A workaround is to be explicit about the view file being rendered, like this:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(view:"/index.gsp")
"500"(view:'/error')
}
}
Issue Links
- is depended upon by
-
GPFREEMARKER-1
is this a bug?
-
The solution mentioned in Freemarker plugin documentation "Fix by setting ... "/"(view:"/index.ftl") if that is what you want to use." not working as per Grails 1.3.5.
Below is exception stack trace:
org.codehaus.groovy.grails.web.mapping.exceptions.UrlMappingException: Error mapping onto view [/index.ftl]: null
org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.renderViewForUrlMappingInfo(UrlMappingsFilter.java:263)
org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:189)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:246)
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:135)
org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:104)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:69)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)