我有一个Action
def index(signupMessage:String="") = addToken {
silhouette.UserAwareAction { implicit request =>
println(s"index action called with request ${utilities.printPlayHttpRequest(request)}")
println(s"index page's argument "+signupMessage)
val Token(name, value) = CSRF.getToken.get
println(s"Token name ${name}, value ${value}")
Ok(views.html.index(/*signupMessage:Option[String]*/messagesApi("app.title")(langs.availables(0))))
}
}
请注意,signupMessage
具有默认值。
我正在如下routes.conf
文件中使用它
GET / controllers.HomeController.index(signupMessage="")
GET /home controllers.HomeController.index(signupMessage="")
GET /home:signup controllers.HomeController.index(signup)
即使我为signupMessage
指定了默认值,我也必须在调用index(signupMessage="")
时指定它的值,因为如果我只执行index(),则会收到错误Using different overloaded methods is not allowed. If you are using a single method in combination with default parameters, make sure you declare them all explicitly.
为什么我不能使用参数的默认值?