你好Grammarians,
文档仅显示:
flashing("success")
如果我使用play
,情况是否永远不会发生?我试过“failure
”& “error
”他们什么都不做
答案 0 :(得分:1)
您可以传入Flash
个实例或String
个元组。它不一定是特定的String
。重要的是,您可以处理任何粘在闪存范围内的内容。
考虑这个例子(Play 2.3.4):
Application.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