I would like to use a different mapping for the same url http://localhost:8080/myapp/ when the user is logged in (session.user)
Actually, as default Im giving开发者_运维知识库 the path when the url is "/" to AppController and 'index' action... but if I try to redirect inside the index action when the user is logged to my UserController (also index action), the path changes to http://localhost:8080/myapp/user/index . That
s not what I`m looking for.
There is a plenty of website (twitter, facebook..) that apply this method, but couldn`t understand how can it be done in Grails, without using the same action for example (AppControlle>index) and render different views when user is active.
static mappings = {
"/"(controller:"app",action:"index")
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"500"(view:'/error')
"404"(view:'/notFound')
}
About your mention about twitter, facebook... I think it's possible that they use different mapping based on the request is POST or GET. In Grails, we can do that kind of mapping like this:
name home: "/" {
controller = [GET: "app", POST: "user"]
action = [GET: "index", POST: "userIndex"]
}
精彩评论