It just takes 15 seconds. Send your
details and we’ll get back to you soon.

How to customize homepage in Grails app

In this blog I want to share how can we customize home page in a Grails application.

In grails, the default homepage is the web-app/index.gsp if we explicitly don`t specify any thing; but of-course that is not sufficient for all apps. We need to have a custom landing page instead of the default page provided by grails.

This can be easily achieved by modifying the URL mappings in UrlMappings.groovy file. 

"/"
{
controller = "yourController"
action = "yourAction"
}

By configuring the URLMappings this way, the home-page of the app will be yourWebApp/yourController/yourAction.

Hope this helps.

-Pradeep Garikipati


Posted in Grails | Tagged , .

5 Responses to How to customize homepage in Grails app

  1. Olivier says:

    Thanks, just what I was looking for…
    Cheers
    Olivier

  2. Giancarlo says:

    Hello,
    It seems this doesn’t work for Oracle Weblogic 11g.
    Any ideas what is the correct config for Oracle Weblogic 11g?

    Thanks!

  3. Meryl Rod says:

    I like assembling useful info, this post has got me even more info!

  4. Muzietto says:

    It seems it’s also not working in my case (version 2.1.0). Which Grails version are you assuming? This syntax is incompatible with the syntax in the present UrlMappings.groovy, where the line related to appwebroot is:

    “/”(view:”/index”)

    Can you please provide a COMPLETE example?

  5. David says:

    It works just fine on Version 2.1.0. There are different formats available whether you are directing to views or controllers.. An example working:

    “/” {
    controller = “admin”
    action = “index”
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 55 = 56

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>