package mainimport "fmt"import "net/http"func home(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "What!")}func bar(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Bar!")}func main() { http.HandleFunc("/", home) http.HandleFunc("/foo", bar) http.ListenAndServe(":5678", nil)}如果我访问/foo,bar将运行。如果我访问/或/any/other/path,home将运行。知道为什么会这样吗?我该如何处理 404?
- 2 回答
- 0 关注
- 173 浏览
添加回答
举报
0/150
提交
取消