ceid-vg
ceid-vg

Reputation: 323

Grails - How to define the starting index page URL

In grails, supposing you have a project named 'MainProject', my default index is http://localhost:8080/MainProject/ and the page associated with this exact url is views/index.gsp.

I would like the starting link of the project NOT to be http://localhost:8080/MainProject/ but something like http://localhost:8080/MainProject/users/login.

I tried to edit the URL Mappings from this:

class UrlMappings {

    static mappings = {
        "/$controller/$action?/$id?(.$format)?"{
            constraints {
                // apply constraints here
            }
        }

        "/"(view: '/index')
        "500"(view:'/error')
    }
}

to this:

class UrlMappings {

    static mappings = {
        "/$controller/$action?/$id?(.$format)?"{
            constraints {
                // apply constraints here
            }
        }

        "/"(view: '/users/login')
        "500"(view:'/error')
    }
}

After the above change, by starting the project, the url remains as http://localhost:8080/MainProject/, but the page shown is not views/index.gsp but views/users/login.gsp. The gsp is correctly rendered, but the url is still not the one I need.

How to solve this?

Upvotes: 0

Views: 240

Answers (1)

adamcooney
adamcooney

Reputation: 398

You can do this with:

"/"(redirect: '/users/login')

Also see Grails URL Mapping Documentation

Upvotes: 1

Related Questions