dseslyh6662605 2014-10-24 07:41
浏览 427

beego,找不到重新定义的页面,404页面未显示html,为什么?

I redefined the page_not_found on router.go,

func page_not_found(rw http.ResponseWriter, r *http.Request) {
    t, _ := template.ParseFiles(beego.ViewsPath + "/404.html")
    data := make(map[string]interface{})

    t.Execute(rw, data)
}

and in init function used

beego.Errorhandler("404", page_not_found)

when i called 404 by used this.Abort("404") in controller, the 404 page was not show html, it showed the page html text, liked this

html text/plain

  • 写回答

1条回答 默认 最新

  • dongnanman9093 2014-10-24 08:34
    关注

    because i wrote 404 html liked this

    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="/static/css/a.css">
    <div class="html404">
        <div class="title">404</div>
            <div class="link">
                <div><a href="/">回首页</a>
                </div>
            </div>
        </div>
    </div>
    

    it caused the question. when i changed the html to

    <html>
    
    <head>
         <title>Aiysea 404 Page</title><link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="/static/css/a.css">
    </head>
    
    <body>
    
        <div class="html404">
            <div class="title">404</div>
                <div class="link">
                    <div><a href="/">回首页</a>
                     </div>
                </div>
            </div>
       </div>
    </body>
    
    </html>
    

    then it gone well.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog