Fix the type of request.Form in 04.1
This commit is contained in:
@@ -55,7 +55,7 @@ This is easy to find out using the `http` package. Let's see how to handle the f
|
||||
fmt.Println("password:", r.Form["password"])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", sayhelloName) // setting router rule
|
||||
http.HandleFunc("/login", login)
|
||||
@@ -84,9 +84,9 @@ Try changing the value of the action in the form `http://127.0.0.1:9090/login` t
|
||||
|
||||

|
||||
|
||||
Figure 4.2 Server prints request data
|
||||
Figure 4.2 Server prints request data
|
||||
|
||||
The type of `request.Form` is `url.Value`. It saves data with the format `key=value`.
|
||||
The type of `request.Form` is `url.Values`. It saves data with the format `key=value`.
|
||||
|
||||
v := url.Values{}
|
||||
v.Set("name", "Ava")
|
||||
|
||||
Reference in New Issue
Block a user