Java Developer

Changing Grails homepage to a particular controller and action

Changing the homepage of a Grails application is very simple. But sometimes simple questions are hard to research and Google. That is why I like collecting mini howtos of many things I encounter in my everyday programming.
The default code for the home is in the GSP file $PROJECT_HOME/grails-app/views/index.jsp

grails_home_index
To change this and point to a controller's action, edit your UrlMappings and change the line of "/".  Example:
class UrlMappings {
    static mappings = {
        "/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        }
        "/" (controller:"person", action:"list")
        "500"(view:'/error')
    }
}
This will load the list action of PersonController.
Tags: action, controller, grails