12345678910111213141516171819202122232425262728293031323334353637 |
- package controllers
-
- type BaseViewController struct {
- BaseController
- }
-
-
-
- // 设置模板
- // 第一个参数模板,第二个参数为layout
- func (this *BaseViewController) SetTpl(template ...string) {
- var tplName string
- layout := ""
- switch {
- case len(template) == 1:
- tplName = template[0]
- case len(template) == 2:
- tplName = template[0]
- layout = template[1]
- default:
- tplName = "index.tpl"
- }
- this.Layout = layout
- this.TplName = tplName
- }
-
- // 重定向
- func (this *BaseViewController) Redirect302(url string) {
- this.Redirect(url, 302)
- this.StopRun()
- }
-
- // 错误页面
- func (this *BaseViewController) Abort404() {
- this.Abort("404")
- }
|