2011-04-22 177 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"] 
} 
相關問題