如果我有以下表单设置:
{{ range $key, $value := .Scores }}
<input id="{{$value.Id}}_rating__1" type="radio" name="rating[{{$value.Id}}]" value="-1">
<input id="{{$value.Id}}_rating__0" type="radio" name="rating[{{$value.Id}}]" value="0">
<input id="{{$value.Id}}_rating__2" type="radio" name="rating[{{$value.Id}}]" value="+1">
{{ end }}
我如何才能正确提取该数据?知道.Scores可以包含多个结构
func categoryViewSubmit(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
log.Fatal(err)
}
fmt.Println("POST")
fmt.Printf("%+v\n", r.Form()) // annot call non-function r.Form (type url.Values)
fmt.Printf("%+v\n", r.FormValue("rating")) // Returns nothing
}
相关分类