diff --git a/MyForm/.idea/Demo01.iml b/MyForm/.idea/Demo01.iml new file mode 100644 index 0000000..b126659 Binary files /dev/null and b/MyForm/.idea/Demo01.iml differ diff --git a/MyForm/login.gtpl b/MyForm/login.gtpl index bdffaf4..0c79cd4 100644 --- a/MyForm/login.gtpl +++ b/MyForm/login.gtpl @@ -6,7 +6,8 @@
用户名: 密码: - + 年龄: +
diff --git a/MyForm/main.go b/MyForm/main.go index 0803ab0..ae5920e 100644 --- a/MyForm/main.go +++ b/MyForm/main.go @@ -41,8 +41,20 @@ func login(w http.ResponseWriter, r *http.Request) { } } else { //请求的是登陆数据,那么执行登陆的逻辑判断 - fmt.Println("username:", r.Form["username"]) - fmt.Println("password:", r.Form["password"]) + fmt.Println("username:", r.Form["username"][0]) + fmt.Println("password:", r.Form["password"][0]) + fmt.Println("age:", r.Form["age"][0]) + if len(r.Form["username"][0]) == 0 { + //为空的处理 + fmt.Println("username is empty!!!") + } + getint, err := strconv.Atoi()(r.Form.Get("age")) + if err != nil { + fmt.Println("this is an error") + } + if getint > 100 { + fmt.Println("too old") + } } }