我有一个 Play 2.5 模板,它从以下声明开始:
@(title: String)(content: Html)(menu:Html = HtmlFormat.empty)(implicit request:Request[AnyContent])
所以第二个参数被声明为具有默认值。
现在在控制器中我有这个动作生成器:
def document(title:String) = Action.async{implicit request =>
documentService.findByTitle(title).map{
case Some(d) => Ok(views.html.document(d))
case None => Ok(main("No document found")(content = Html("There is no such document")))
}
}
所以我没有将menu
参数的值传递给模板调用,我希望它能够按照默认参数值语义进行编译和工作,但是我收到了这个编译错误:
[error] D:\Projects\feed\app\controllers\MainController.scala:28: missing arguments for method apply in class main;
[error] follow this method with `_' if you want to treat it as a partially applied function
[error] case None => Ok(main("No document found")(content = Html("There is no such document")))
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
你能解释一下这里有什么问题吗?