Cách phân tích mảng biểu mẫu html bằng Beego.Cách phân tích mảng biểu mẫu trong golang Beego
<input name="names[]" type="text" /> <input name="names[]" type="text" /> <input name="names[]" type="text" />
Go Beego
type Rsvp struct {
Id int `form:"-"`
Names []string `form:"names[]"`
}
rsvp := Rsvp{}
if err := this.ParseForm(&rsvp); err != nil {
//handle error
}
input := this.Input()
fmt.Printf("%+v\n", input) // map[names[]:[name1 name2 name3]]
fmt.Printf("%+v\n", rsvp) // {Names:[]}
Tại sao phương pháp Beego ParseForm trả về một tên trống rỗng?
Cách nhận giá trị vào rsvp.Names?