Reputation: 71
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
Upvotes: 2
Views: 1749
Reputation: 71
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.
Upvotes: 1