Default Grails '/' controller mapping not resolving properly
This one has been driving me crazy today. Since upgrading to Grails 1.2 and Weblogic 10.3 the default root mapping for "/" stopped working. Here's what I have...
I have this URL mapping:
"/"(controller:"IGive", action:"inde开发者_JAVA百科x" )
I have a controller named IGiveController with an index closure
def index = {
render "foo"
}
When I go to my application running in the embedded Tomcat and Jetty with http://localhost:8080/mycontext/ I get "foo" returned property. But when I build a war and deploy to Weblogic 10.3 I get a 404.
I downgraded to Grails 1.1.2 and it still didn't work on Weblogic 10.3 but the error was more descriptive
Could not open ServletContext resource [/WEB-INF/grails-app/views/index.gsp]
So it seems like it's completely ignoring my URL Mapping for "/" but other URL Mappings that are deeper are working. Any clues??
I think this is more related to Weblogic - I am seeing the same on Weblogic 9.2 - but not on Tomcat or Jetty. Doesn't hit my UrlMapping:
"/"(controller: 'home', action: 'index')
I think Weblogic is being smart and converting / -> index.gsp which then comes back as a 404.
There is a slightly ugly workaround - just add a mapping like this:
"/index.gsp"(controller: 'home', action: 'index')
and that seems to do the trick. Anyone have a better way to fix this???
It might be related to a Grails 1.2 bug. See GRAILS-5609 and this thread in Grails forum. It is fixed in 1.2.1. It seems that 1.2 introduced some regression bugs with UrlMappings...
精彩评论