Configuring the Grails Root Application Context

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.

 

13 thoughts on “Configuring the Grails Root Application Context

  1. Mike

    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?

    Reply
  2. Ronny

    “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

    Reply
  3. Pingback: grails 2.0 – correct use of serverURL for production? | PHP Developer Resource