Merge pull request #71 from yecrane/master
form获取相同名字的对象数组值
Showing
1 changed file
with
12 additions
and
0 deletions
| ... | @@ -261,6 +261,18 @@ func (c *Controller) GetString(key string) string { | ... | @@ -261,6 +261,18 @@ func (c *Controller) GetString(key string) string { |
| 261 | return c.Input().Get(key) | 261 | return c.Input().Get(key) |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | func (c *Controller) GetStrings(key string) []string { | ||
| 265 | r := c.Ctx.Request; | ||
| 266 | if r.Form == nil { | ||
| 267 | return []string{} | ||
| 268 | } | ||
| 269 | vs := r.Form[key] | ||
| 270 | if len(vs) > 0 { | ||
| 271 | return vs | ||
| 272 | } | ||
| 273 | return []string{} | ||
| 274 | } | ||
| 275 | |||
| 264 | func (c *Controller) GetInt(key string) (int64, error) { | 276 | func (c *Controller) GetInt(key string) (int64, error) { |
| 265 | return strconv.ParseInt(c.Input().Get(key), 10, 64) | 277 | return strconv.ParseInt(c.Input().Get(key), 10, 64) |
| 266 | } | 278 | } | ... | ... |
-
Please register or sign in to post a comment