0
從2.4.8將我的項目升級到Play Framework 2.5.4後,我在處理會話時遇到問題。有這樣的方法,我的控制器來測試問題:升級到Play Framework 2.5.4後,會話不起作用Scala
def test = Action { implicit request =>
Redirect(controllers.routes.Carts.test2()).withSession(new Session(Map("user" -> "customer")))
}
def test2 = Action { implicit request =>
Ok(request.session.data.toString())
}
基本上test
方法增加了會話和重定向到test2
方法。當我打開網頁測試方法URL重定向後,我得到什麼,我需要在瀏覽器:
地圖(用戶 - >客戶)
但是,如果我以後刷新頁面我越來越:
地圖(csrfToken - > ce1a6222484f378d38ab3534c2b400191270395d-1470238791014-c988ce3fe47259173166949a)
因此,似乎會話僅適用於一個請求,然後用csrfToken覆蓋。我禁用了所有的過濾器。我與過濾器類如下所示:
class Filters @Inject()() extends HttpFilters {
val filters = Seq.empty
}
不明白什麼是錯我的代碼。升級前相同的代碼工作正常。
你在瀏覽器刷新,而無需再次做重定向? – marcospereira
@marcospereira是的,只需刷新瀏覽器 – user2975535
你可以顯示你的配置(application.conf) – aravindKrishna