Sunday, April 15, 2012

Using the Root Application Context ('/') in Grails

Hi all,

Its been a long time since I posted on this blog (since June of last year!) but as I was trying to remember how I did something only a week ago I was reminded of why posting to this blog is useful - for me at least!

To get you up to speed, I have been investigating and enjoying Grails, a 'rails-like' web application platform built on Groovy and Java. 'Rails-like' is best mentioned in quotes because a lot of Grails fans will tell you that the similarity is only skin-deep. I don't know Ruby on Rails well enough to comment (oh but how many create-a-blog tutorials have I done?) but I am surprised by how deep Grails is.

In any case, the nugget of information I would like to share today is how to get Grails 2.* to publish to root context. By convention Grails will publish to an application context the same as or derived from your application name. When running the local development server this would mean your application would be hosted at and below http://localhost:8080/myapp/.

To publish to the root application context you can add the following line to your conf/Config.groovy file: = '/'

Pretty simple. My understanding on J2EE application contexts pretty limited but the above setting can be overridden during the deployment anyway (Heroku, which provides hosting for Grails amongst other platforms, does this).

No comments:

Post a Comment