我正在开发beego应用程序。我试图在两台不同的机器上运行相同的代码。两者都是ubuntu。在一台机器上,它运行没有任何问题,但在另一台机器上,我得到了以下错误日志。我对这两个文件都有相同的文件结构,您认为为什么会发生这种情况?
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 controllers
import (
"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()
}发布于 2016-01-28 14:10:02
我找到问题了。Beego在我安装的机器之间发布了新版本。我认为它不能看到整个控制器,但它只是函数的名称。
在新版本中:
serveJson() -> serveJSON()配置也发生了变化。
Beego.HttpPort -> beego.BConfig.Listen.HTTPPort发布于 2019-02-08 11:56:47
Beego版本1.11.1
这是区分大小写的。
变化
this.ServeJson()至
this.ServeJSON()https://stackoverflow.com/questions/35046511
复制相似问题