Nick Carroll

Metabolising caffeine into code

Configuring the Grails Root Application Context

with 11 comments

By default if you create a Grails application called funkysite (i.e. you did grails create-app funkysite on the command line), then when you run your application the root context is set to /funkysite. This means that your controllers such as a UserController with a show action will be available at http://localhost:8080/funkysite/user/show. Having “funkysite” as the root context is redundant, especially if you want to host your application at http://funkysite.com/funkysite/user/show.

My preference is to just have “/” as the root application context. Fortunately, you can easily configure the root application context in Grails. All you need to do is edit conf/Config.groovy and add grails.app.context = “/”. This will set your root application context to “/”, so that the above UserController and show action will be available at http://localhost:8080/user/show.

Written by Nick

March 27th, 2009 at 11:24 pm

Posted in Programming

Tagged with , ,

11 Responses to 'Configuring the Grails Root Application Context'

Subscribe to comments with RSS or TrackBack to 'Configuring the Grails Root Application Context'.

  1. Nice tip! What do you do when you go to deploy a WAR file then? Does it work the same way or do you have to configure something on the app server?

    Mike

    28 Mar 09 at 1:55 am

  2. Thanks for the tip, Being a non grails application expert, i could do the job of grails expert with the help of your tip.

    Vaibhav

    25 Aug 09 at 8:30 pm

  3. Thank you, thank you, thank you.

    Stephen

    1 Dec 09 at 5:20 am

  4. Great! Very helpful,thaks

    alexey

    14 Dec 09 at 3:48 pm

  5. Finally I found how to do this. Thank you!

    Andrey

    1 Jan 10 at 2:52 am

  6. “What do you do when you go to deploy a WAR file then? Does it work the same way or do you have to configure something on the app server?”

    At least for Jetty and Tomcat you just deploy your war with the magic name ROOT.war instead of e.g. funkysite.war

    Ronny

    27 May 10 at 12:33 am

  7. Great! None of my Grails books lost a word on this topic. Thanks a lot!

    Regards

    Marc O. Kneifel

    14 Jul 10 at 6:09 pm

  8. Sik tip brub. big up to the OG tripple OG!

    sham

    29 Jul 10 at 4:39 am

  9. Sik tip bruv. big up to the OG tripple OG!

    sham

    29 Jul 10 at 4:39 am

  10. Thanks – worked perfect for me.

    John Thompson

    31 Jan 11 at 1:07 am

  11. Great! Thanks

    Vijay Santhanam

    24 Apr 11 at 11:42 pm

Leave a Reply