master
ZGGSONG 3 years ago
parent ccd45219ee
commit aae77adedf

Binary file not shown.

@ -6,7 +6,8 @@
<form action="/login" method="post"> <form action="/login" method="post">
用户名:<input type="text" name="username"> 用户名:<input type="text" name="username">
密码:<input type="password" name="password"> 密码:<input type="password" name="password">
<input type="submit" value="登陆"> 年龄:<input type="text" name="age">
<input type="submit" value="提交">
</form> </form>
</body> </body>
</html> </html>

@ -41,8 +41,20 @@ func login(w http.ResponseWriter, r *http.Request) {
} }
} else { } else {
//请求的是登陆数据,那么执行登陆的逻辑判断 //请求的是登陆数据,那么执行登陆的逻辑判断
fmt.Println("username:", r.Form["username"]) fmt.Println("username:", r.Form["username"][0])
fmt.Println("password:", r.Form["password"]) 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")
}
} }
} }

Loading…
Cancel
Save