亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Martini 綁定似乎不起作用

Martini 綁定似乎不起作用

Go
繁花不似錦 2021-08-10 20:42:53
我正在玩 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 關注
  • 200 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號