在beego里面输出JSONP使用的方法是
mystruct := map[string]string{"Id": "22"}
this.Data["jsonp"] = &mystruct
this.ServeJSONP()
但是我写的时候出现错误页面,这个时候BeeGo的官方程序员告诉我加上
this.EnableRender = false
停止渲染。
这个只是一个引子,我是想输出content-type
为 application/javascript 这个格式。我读了源码找到了方法
this.Ctx.Output.Header("Content-Type", "application/javascript; charset=utf-8")
this.TplName = "your.tpl"