beego,未找到重新定义的页面,404页面未显示html,为什么?
我重新定义了router.go上找不到的beego,未找到重新定义的页面,404页面未显示html,为什么?,html,go,http-status-code-404,beego,Html,Go,Http Status Code 404,Beego,我重新定义了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) } 在init函数中使用 beego.Errorhandler(“4
页面
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)
}
在init
函数中使用
beego.Errorhandler(“404”,未找到页面)
当我在控制器中使用this.Abort(“404”)
调用404时,404页面没有显示html,它显示了页面html文本,如下所示
<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>
因为我写了404 html,我喜欢这样
<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>
404
这引起了一个问题。当我将html更改为
<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>
Aiysea404页
404
然后一切顺利。正常错误。请务必提及内容类型()。你的404.html页面也这样做吗?我将404.html更改为普通html,然后它就工作了。你是说你在404.html页面的代码源中做了一些更改吗?是的,如下面的答案。非常好。然后是一个实际的html页面+1.