form 提交的数据,表单验证出现错误后,如何像 Laravel 中的 blade 一样处理?

RT.

Study hard and make progress every day. Study hard and make progress every day.
pardon110
最佳答案

Iris的session实现,有存储类似错误消息这类用过即丢的一次性Flash方法如下。然后你需要考虑的就是在中间件或请求中,将错误信息放到flash session内即可,也可通过ctx.Value() 对象存储。或者考虑在iris的mvc应用BeforeActivation方法内作手脚。

SetFlash(key string, value interface{})
HasFlash() bool
GetFlashes() map[string]interface{}

PeekFlash(key string) interface{}
GetFlash(key string) interface{}
GetFlashString(key string) string
GetFlashStringDefault(key string, defaultValue string) string

DeleteFlash(key string)
ClearFlashes()
4年前 评论
mouyong (楼主) 4年前
讨论数量: 1
pardon110

Iris的session实现,有存储类似错误消息这类用过即丢的一次性Flash方法如下。然后你需要考虑的就是在中间件或请求中,将错误信息放到flash session内即可,也可通过ctx.Value() 对象存储。或者考虑在iris的mvc应用BeforeActivation方法内作手脚。

SetFlash(key string, value interface{})
HasFlash() bool
GetFlashes() map[string]interface{}

PeekFlash(key string) interface{}
GetFlash(key string) interface{}
GetFlashString(key string) string
GetFlashStringDefault(key string, defaultValue string) string

DeleteFlash(key string)
ClearFlashes()
4年前 评论
mouyong (楼主) 4年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!