golang The system cannot find the path specified.
发布时间:2020-12-16 18:28:06 所属栏目:大数据 来源:网络整理
导读:指定的路径有误 package main import ( "net/http" "fmt" "strings" "log" "html/template" ) func sayHelloName (w http.ResponseWriter , r *http.Request) { r. ParseForm () ; fmt. Println (r.Form) fmt. Println (r.URL.Path) fmt. Println (r.URL.Sch
指定的路径有误 package main import ( "net/http" "fmt" "strings" "log" "html/template" ) func sayHelloName(w http.ResponseWriter,r *http.Request) { r.ParseForm(); fmt.Println(r.Form) fmt.Println(r.URL.Path) fmt.Println(r.URL.Scheme) fmt.Println(r.Form["url_long"]) for k,v:= range r.Form{ fmt.Println("key: ",k) fmt.Println("value:",strings.Join(v,"")) } fmt.Fprintln(w,"hello nihao") } func login(w http.ResponseWriter,r *http.Request) { fmt.Println("method: ",r.Method) if r.Method == "GET" { t,err := template.ParseFiles("src/html/login.gtpl") if err != nil { fmt.Println(err) return } t.Execute(w,nil) } else { fmt.Println("username: ",r.Form["username"]) fmt.Println("password: ",r.Form["password"]) } } func main() { //http.HandleFunc("/",sayHelloName); http.HandleFunc("/login",login) err:= http.ListenAndServe(":9090",nil) if err != nil { log.Fatalf("Listen and server",err) } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |