指定的路径有误
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) } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。