#beego项目源码学习#控制器: 

 package controllers


import (

        "github.com/astaxie/beego"

)


type MainController struct {

        beego.Controller

}


func (this *MainController) Get() {

        this.Data["Website"] = "beego.me"

        this.Data["Email"] = "astaxie@gmail.com"

        this.TplName = "index.tpl"

}

而 beego.Controller 拥有很多方法,其中包括 InitPreparePostGetDeleteHead 等方法。我们可以通过重写的方式来实现这些方法,而我们上面的代码就是重写了 Get 方法。