在路线中,如何使用动态操作名称,例如1.x中的{action}。是否有路由文件的详细语法语句?
在1.x中,路由会将localhost / page / zzz?xxx = yyy转移到带路由的动作zzz
GET /{controller}/{action} {controller}.{action}
答案 0 :(得分:3)
你不能在这个级别上做到这一点。 但是,您可以编写一个调用程序,它将使用反射动态调用操作...
GET /:controller/:action controllers.Invoker.invoke(controller, action)
invoke
看起来像这样:
object Invoker extends Controller {
def invoke(controllerName: String, actionName: String) = Action { request =>
// Retrieve the action using reflection and invoke it
}
}