我正在研究 beego 應(yīng)用程序。我試圖在兩臺(tái)不同的機(jī)器上運(yùn)行相同的代碼。兩者都是ubuntu。在一臺(tái)機(jī)器上,它運(yùn)行沒(méi)有任何問(wèn)題,但在另一臺(tái)機(jī)器上我得到了以下錯(cuò)誤日志。我對(duì)兩者都有相同的文件組織,您認(rèn)為為什么會(huì)發(fā)生這種情況?controllers/EventController.go:18: this.ServeJson undefined (type *EventController has no field or method ServeJson)controllers/EventController.go:24: this.ServeJson undefined (type *EventController has no field or method ServeJson)controllers/EventController.go:30: this.ServeJson undefined (type *EventController has no field or method ServeJson)controllers/default.go:14: c.TplNames undefined (type *MainController has no field or method TplNames)偶控制器:package controllersimport ( "github.com/astaxie/beego" "solardatabase/models" "solardatabase/dao" "solardatabase/services")type EventController struct { beego.Controller}func (this *EventController) ListEvents() { res := struct{ Tasks []*models.Event }{dao.GetAllEvents()} this.Data["json"] = res this.ServeJson()}func (this *EventController) ListEventsByRange() { request, _ := models.CreateEventByTimeRangeRequest(this.Ctx.Input) this.Data["json"] = dao.EventsByTimeRange(request) this.ServeJson()}func (this *EventController) TemporalQuery() { request, _ := models.CreateTemporalRequest(this.Ctx.Input) this.Data["json"] = services.EventsByTimeFilter(request) this.ServeJson()}
2 回答

絕地?zé)o雙
TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊
我發(fā)現(xiàn)了問(wèn)題。Beego 在我安裝機(jī)器之間發(fā)布了新版本。我以為它看不到整個(gè)控制器,但它只是函數(shù)的名稱(chēng)。
在新版本中:
serveJson() -> serveJSON()
配置也改變了。
Beego.HttpPort -> beego.BConfig.Listen.HTTPPort

德瑪西亞99
TA貢獻(xiàn)1770條經(jīng)驗(yàn) 獲得超3個(gè)贊
Beego 1.11.1 版本
這是區(qū)分大小寫(xiě)的。
改變
this.ServeJson()
到
this.ServeJSON()
- 2 回答
- 0 關(guān)注
- 178 瀏覽
添加回答
舉報(bào)
0/150
提交
取消