Update controller.go
form获取相同名字的对象数组值
Showing
1 changed file
with
12 additions
and
0 deletions
| ... | @@ -241,6 +241,18 @@ func (c *Controller) GetString(key string) string { | ... | @@ -241,6 +241,18 @@ func (c *Controller) GetString(key string) string { |
| 241 | return c.Input().Get(key) | 241 | return c.Input().Get(key) |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | func (c *Controller) GetStrings(key string) []string { | ||
| 245 | r := c.Ctx.Request; | ||
| 246 | if r.Form == nil { | ||
| 247 | return []string{} | ||
| 248 | } | ||
| 249 | vs := r.Form[key] | ||
| 250 | if len(vs) > 0 { | ||
| 251 | return vs | ||
| 252 | } | ||
| 253 | return []string{} | ||
| 254 | } | ||
| 255 | |||
| 244 | func (c *Controller) GetInt(key string) (int64, error) { | 256 | func (c *Controller) GetInt(key string) (int64, error) { |
| 245 | return strconv.ParseInt(c.Input().Get(key), 10, 64) | 257 | return strconv.ParseInt(c.Input().Get(key), 10, 64) |
| 246 | } | 258 | } | ... | ... |
-
Please register or sign in to post a comment