func sayHello(w http.ResponseWriter, r *http.Request) { r.ParseForm()//获取请求参数 fmt.Fprintf(w, "hello world")//返回前台页面}func saystu(w http.ResponseWriter, r *http.Request) { r.ParseForm() fmt.Fprintf(w, "hello student")}func main() { fmt.Print("com in") http.HandleFunc("/test", sayHello) http.HandleFunc("/test2", saystu) err := http.ListenAndServe(":80", nil) if err != nil { log.Fatal("ListenAndServe", err) }}
访问: