运行golang项目后文件无法访问 出现 404 404 page not found
func main() {
fmt.Println("Linwute 2022-07-29")
//解决静态文件访问 404
//http.Handle("/", http.FileServer(http.Dir("./upload"))) //根目录方式
//访问服务器目录./public文件夹里的内容,可以通过 http://localhost:3000/static来进行访问。
http.Handle("/upload/", http.StripPrefix("/upload/", http.FileServer(http.Dir("./upload"))))
http.Handle("/file/", http.StripPrefix("/file/", http.FileServer(http.Dir("./file"))))
//... 其他业务代码
}部署golang项目 图片和文件无法访问
通过链接 golang项目下文件夹的 图片和文件无法访问
出现 404 404 page not found