【问题标题】:what options can be passed to flashing in play framework哪些选项可以传递给 flash in play 框架
【发布时间】:2014-11-26 05:50:24
【问题描述】:

你好,语法学家,

文档只显示:

flashing("success")

如果我使用play,就不会发生故障吗?我试过“failure”和“error”他们什么也没做

【问题讨论】:

标签: scala playframework playframework-2.0


【解决方案1】:

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

考虑这个例子(播放 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

【讨论】:

    猜你喜欢
    • 2021-01-20
    • 2021-04-20
    • 2017-04-06
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多