我正在玩 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 回答
- 1 回答
- 0 关注
- 171 浏览
添加回答
举报
0/150
提交
取消