哪些选项可以传递给flash in play框架



你好,Grammarians,

文档仅显示:

flashing("success")

如果我使用play,故障永远不会发生吗?我试过"failure"&"error"他们什么都不做

您可以传入Flash实例或String s的元组。它不必是特定的String。重要的是,你要处理好你粘在闪光灯范围内的任何东西。

考虑这个例子(播放2.3.4):

应用程序.scala

package controllers
import play.api.mvc._
object Application extends Controller {
  def index = Action { implicit req =>
    Redirect(routes.Application.flash()).flashing("something" -> "show this text")
  }
  def flash = Action { implicit req =>
    Ok(views.html.index("Flash!"))
  }
}

index.scala.html

@(title: String)(implicit flash: Flash)
<!DOCTYPE html>
<html>
  <head>
    <title>@title</title>
  </head>
  <body>
    <h1>@flash.get("something")</h1>
  </body>
</html>

路由

# Home page
GET        /                    controllers.Application.index
GET        /flash               controllers.Application.flash

最新更新