Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the default homepage in a Grails application?

Tags:

grails

What is the configuration setting for modifying the default homepage in a Grails application to no longer be appName/index.gsp? Of course you can set that page to be a redirect but there must be a better way.

like image 395
Ed.T Avatar asked Aug 26 '08 12:08

Ed.T


4 Answers

Add this in UrlMappings.groovy

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

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

(cut/pasted from IntelliGrape Blog)

like image 58
Bob Herrmann Avatar answered Nov 18 '22 05:11

Bob Herrmann


Edit UrlMappings.groovy

Add for example add this rule, to handle the root with a HomeController.

"/"(controller:'home')

like image 22
dahernan Avatar answered Nov 18 '22 04:11

dahernan


You may try as follows
in the UrlMappings.groovy class which is inside the configuration folder:

class UrlMappings {

    static mappings = {

        "/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        }

        //"/"(view:"/index")
        "/" ( controller:'Item', action:'index' ) // Here i have changed the desired   action to show the desired page while running the application
        "500"(view:'/error')
    }
}

hope this helps,
Rubel

like image 12
Rashedul.Rubel Avatar answered Nov 18 '22 04:11

Rashedul.Rubel


Use controller, view and action parameter by the following syntax:

class UrlMappings {
   static mappings = {
       "/" (controller:'dashboard', view: 'index', action: 'index')
       "500"(view:'/error')
   }
}
like image 4
Robert Erlinger Avatar answered Nov 18 '22 04:11

Robert Erlinger