不用,拼接,对于名字一样的form元素,Go会用[]string来存储的。 比如: package main import ( "net/http" ) type helloHandler struct{} func (h *helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.ParseForm() if ids, existed := r.PostForm["id"]; existed { for _, id := range ids { w.Write([]byte(id + ",")) } } } func main() { http.Handle("/", &helloHandler{}) http.ListenAndServe(":12345", nil) } 假设传入: <input name="id" value="1" /> <input name="id" value="2" /> curl 'http://127.0.0.1:12345' -d 'id=1&id=2' 会输出结果: 1,2,
不用,拼接,对于名字一样的form元素,Go会用
[]string
来存储的。比如:
假设传入:
会输出结果: