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

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

如何在Echo框架中綁定多部分/表單數據數組?

如何在Echo框架中綁定多部分/表單數據數組?

Go
天涯盡頭無女友 2022-10-04 17:17:34
我正在使用顫振和Go Echo框架編寫一個api服務器,我想從顫動到Go發送數據并保存它,但在Go中不起作用:c.bind()type _getData struct {    Title    string      `json:"title" form:"title"`    Address  string      `json:"address" form:"address"`    Location string      `json:"location" form:"location"`    MapId    uint        `json:"map_id" form:"map_id"`    Date     _customTime `json:"date" form:"date"`    Pages    []struct {        Order       int    `json:"order" form:"order"`        Description string `json:"description" form:"description"`    } `json:"pages" form:"pages"`    Tags []struct {        TagName string `json:"tag_name" form:"tag_name"`        ID      string `json:"id" form:"id"`    } `json:"tags" form:"tags"`}type _customTime struct {    time.Time}創建一個結構,如上面的代碼所示,并按如下所示進行綁定:d := &echo.DefaultBinder{}var aa _getDatad.Bind(&aa, c)fmt.Println(c.Request().Form)fmt.Println(aa)----- fmt.Println(c.Request().Form)'s result is -----ap[address:[?? ????? ????? ??? ???? ] date:[2021-10-01] location: [37.330672396748554 -122.03014377504589] pages[0][description]:[123123] pages[0] [order]:[0] tags[0][tag_name]:[sdf] title:[123123]]----- fmt.Println(aa)'s result is -----{123123 ?? ????? ????? ??? ????  37.330672396748554 -122.03014377504589 0 2021-10-01 00:00:00 +0900 KST [] []}頁面和標記數據未綁定。其他字段是綁定的,但為什么不只是多數組字段?如何綁定?我是初學者,任何建議將不勝感激。
查看完整描述

1 回答

?
POPMUISE

TA貢獻1765條經驗 獲得超5個贊

Echo 框架不支持從現成的表單數據綁定數組。

您可以改用 json 或使用第三方庫。查看實施發布和 github 問題 https://github.com/labstack/echo/issues/1644


查看完整回答
反對 回復 2022-10-04
  • 1 回答
  • 0 關注
  • 139 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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