2014-10-01 77 views
1

你好文法閃爍,哪些選項可以傳遞給在遊戲框架

文檔只顯示: 閃爍(「成功」)

如果我使用起到不要失敗永遠不會發生?香港專業教育學院嘗試「失敗」 &「錯誤」,他們不做任何事情

感謝

+1

HTTPS:/ /www.playframework.com/documentation/2.3.x/api/scala/index.ht毫升#play.api.mvc.Flash – 2014-10-01 13:20:45

回答

1

您可以通過在Flash實例或String小號元組。它不一定是一個具體的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