如何省略“控制器”。 Play路径文件中的前缀?

时间:2014-02-24 13:56:03

标签: routes playframework-2.0

在Play 2.2中,我的routes文件中包含以下常用条目:

GET   /                     controllers.Application.show(page = "home")
GET   /:page                controllers.Application.show(page)
GET   /blah                 controllers.Blah.blah()

有什么办法可以省略这个文件中的controllers.前缀吗?

1 个答案:

答案 0 :(得分:2)

看起来不像现在这样。在解析路由文件语法时,RoutesCompiler正在寻找绝对方法:

来自:framework/src/routes-compiler/src/main/scala/play/router/RoutesCompiler.scala#L202

def absoluteMethod: Parser[List[String]] = namedError(javaIdent ~ "." ~ javaIdent ~ "." ~ rep1sep(javaIdent, ".") ^^ {
  case first ~ _ ~ second ~ _ ~ rest => first :: second :: rest
}, "Controller method call expected")