2011-04-22 83 views
0

我想用一个不同的映射为相同的URL http://localhost:8080/myapp/当用户(session.user)登录不同的映射为相同的URL

其实,默认我m 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不是什么我在找对于。

有很多应用此方法的网站(twitter,facebook ..),但无法理解它如何在Grails中完成,而不使用相同的动作(例如AppControlle> index)并渲染不同用户活动时的视图。

static mappings = { 
    "/"(controller:"app",action:"index") 

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

    "500"(view:'/error') 
    "404"(view:'/notFound') 
    } 

回答

1

关于您提到的关于twitter,facebook ...我认为他们使用基于请求的不同映射可能是POST或GET。在Grails中,我们可以这样做:

name home: "/" { 
    controller = [GET: "app", POST: "user"] 
    action = [GET: "index", POST: "userIndex"] 
} 
相关问题