FlashData的使用:
存儲(chǔ)
flash :beego.NewFlash()
flash.Set(key, value)? // flash.Error(msg)? flash.Success(msg)? flash.Warning(msg)? flash.Notice(msg)
flash.Store(&c.Controller)? //Controller為beego的Controller
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//flash.Store會(huì)將數(shù)據(jù)存儲(chǔ)到Controller的cookie中? ? =>? c.Ctx.SetCookie
獲取
beego.ReadFromRequest(&c.Controller)? //將會(huì)自動(dòng)flash中的數(shù)據(jù)設(shè)置到Controller中Data中,即c.Data["flash"] = flash.Data,其中flash的Data字段為map[string]string類型。
參考資料:
【1】go:beego FlashData結(jié)構(gòu)體&方法