获取参数
===
### beego 获取 get、post 参数
`value := c.GetString("key")`
~~~
type MainController struct {
beego.Controller
}
func (c *MainController) Get() {
name := c.GetString("name")
log.Println(name)
c.Data["Name"] = name
c.Data["Website"] = "beego.me"
c.Data["Email"] = "astaxie@gmail.com"
c.TplName = "index.tpl"
}
type ResponseJson map[string]interface{}
func (c *MainController) Post() {
name := c.GetString("name")
data := &ResponseJson{
"name":name,
}
bytes, _ := json.Marshal(data)
c.Ctx.ResponseWriter.Header().Set("Content-type","application/json")
c.Ctx.Output.Body(bytes)
}
~~~