如何获取 flash scope - Play Framework with Scala,模板中的最大参数
How to obtain flash scope - Play Framework with Scala, maximum arguments in template
看了2013年写的play with scala这本书,发现最新的play版本有些问题。其中之一是 i18n Messages,我成功解决了。但是现在又遇到了一个问题,就是:
作者解释了闪光范围。在书中的例子中有这样的东西:
(在 main.scala.html 模板内)
@(title: String)(content: Html)(implicit flash: Flash)
但在我的代码中它必须是:
@(title: String)(content: Html)(implicit messages: Messages)(implicit flash: Flash)
这就是问题所在。当我添加 (implicit flash: Flash) 时,我的 IDE (IntelliJ IDEA) 收到错误消息:"wrong top statement declaration"
我想模板有最大数量的参数(据我所知模板是函数)所以我不能再添加一个。问题是如何获取flash scope对象?
请解释一下这些参数的概念。谢谢!
一个函数中只能有一个隐式参数列表,而且必须是最后一个,像这样:@(title: String)(content: Html)(implicit messages: Messages, flash: Flash)
看了2013年写的play with scala这本书,发现最新的play版本有些问题。其中之一是 i18n Messages,我成功解决了。但是现在又遇到了一个问题,就是:
作者解释了闪光范围。在书中的例子中有这样的东西: (在 main.scala.html 模板内)
@(title: String)(content: Html)(implicit flash: Flash)
但在我的代码中它必须是:
@(title: String)(content: Html)(implicit messages: Messages)(implicit flash: Flash)
这就是问题所在。当我添加 (implicit flash: Flash) 时,我的 IDE (IntelliJ IDEA) 收到错误消息:"wrong top statement declaration"
我想模板有最大数量的参数(据我所知模板是函数)所以我不能再添加一个。问题是如何获取flash scope对象?
请解释一下这些参数的概念。谢谢!
一个函数中只能有一个隐式参数列表,而且必须是最后一个,像这样:@(title: String)(content: Html)(implicit messages: Messages, flash: Flash)