From 27896c570054f06bcd95ea729aead8cce4e582be Mon Sep 17 00:00:00 2001 From: yecrane Date: Mon, 17 Jun 2013 16:12:35 +0900 Subject: [PATCH] Update controller.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit form获取相同名字的对象数组值 --- controller.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/controller.go b/controller.go index b7804f33..bc06b946 100644 --- a/controller.go +++ b/controller.go @@ -241,6 +241,18 @@ func (c *Controller) GetString(key string) string { return c.Input().Get(key) } +func (c *Controller) GetStrings(key string) []string { + r := c.Ctx.Request; + if r.Form == nil { + return []string{} + } + vs := r.Form[key] + if len(vs) > 0 { + return vs + } + return []string{} +} + func (c *Controller) GetInt(key string) (int64, error) { return strconv.ParseInt(c.Input().Get(key), 10, 64) }