我正在學習 Go,但在使用我的服務器提供靜態文件時遇到了問題。我總是得到 404。請求是為了http://localhost:3001/static/breakfast.jpg路由器+文件服務器mux := chi.NewRouter() mux.Get("/", handlers.Repo.Home)fileServer := http.FileServer(http.Dir("./static/"))mux.Handle("/static/*", http.StripPrefix("/static", fileServer))靜態文件路徑root/static/我的模板主頁.tmpl{{template "base" .}}{{define "content"}}<div class="container"> <div class="row"> <div class="col"> <h1>Hi from home page</h1> <img src="/static/breakfast.jpg" width="1920" height="1080" alt="house" /> </div> </div></div>{{ end }}我究竟做錯了什么?
- 1 回答
- 0 關注
- 92 瀏覽
添加回答
舉報
0/150
提交
取消