我正在玩 Martini,但由于某種原因,我無法讓 contrib 綁定包工作。我的結構沒有綁定到值。我已將代碼簡化為最簡單的形式,但它仍然不起作用。誰能看到我做錯了什么?package mainimport ( "github.com/go-martini/martini" "github.com/martini-contrib/binding" "net/http")var html string = `<form method="POST" enctype="application/x-www-form-urlencoded"><input name="un" type="text" /><input type="submit" value="Some button" /></form>`type FormViewModel struct { Username string `form: "un"`}func main() { m := martini.Classic() m.Get("/", func(w http.ResponseWriter) { w.Header().Add("content-type", "text/html") w.Write([]byte(html)) }) m.Post("/", binding.Form(FormViewModel{}), func(vm FormViewModel) string { return "You entered: " + vm.Username }) m.Run()}
- 1 回答
- 0 關注
- 200 瀏覽
添加回答
舉報
0/150
提交
取消
