2016-04-21 14 views

回答

0

您可以使用此訪問:

// Redirect to /hello/Bob 
def helloBob = Action { 
    Redirect(routes.Application.hello("Bob")) 
} 

,你可以在playframework文檔中看到。

https://playframework.com/documentation/2.3.x/ScalaRouting

但是,如果你的意思是,你有數倍的控制器和他們分成套票,並希望訪問這些內部另一另一個控制器。您可以使用像這樣實現它:

controllers.packageName.routes.ControllerName.functionInsideController

+0

它的工作很好,但我還有一個問題。如何反向路由控制器。例如,其路由文件位於subroute.routes中。 – Srini

+0

@srini如果我理解你的問題,你可以在conf-> routes文件中定義所有的路由。除此之外,您可以定義其他方式,但默認情況下,您將所有路由放在同一個文件中,而且它們來自不同的包。例如:GET/route1 \t \t controllers.classControler1.definition GET/route2 \t \t controllers.classControler2.definition' – Trp

0

嘗試創建一個新的路由前:subcontrollers.routes

main routes Ex: 
-> /subcontrollers subcontrollers.Routes 

subcontrollers.routes Ex: 
    # Map static resources from the /public folder to the /assets URL path 
    GET /assets/*file       controllers.subcontrollers.Assets.at(path="/public", file) 

    GET /example       controllers.subcontrollers.SubController.sample(parameter1:Long,parameter2: String) 

Reference Link