所以,我在 html 中有这个表单。它旨在对/subscribe页面进行 POST 请求:
<html>
<form action="/subscribe" method="post">
First Name: <input type="text" name="first_name" placeholder="Willy"/><br/>
Last Name: <input type="text" name="last_name" placeholder="Warmwood"/><br/>
Email: <input type="email" name="email" placeholder="willy.warwood@gmail.com"/><br/>
<input type="submit" value="Submit"/>
</form>
</html>
然后,我在 golang 中有这个路由器:
http.HandleFunc("/subscribe/", SubscribeHandler)
golang中的这个处理程序:
func SubscribeHandler(w http.ResponseWriter, r *http.Request) {
log.Println(r.Method)
}
但问题是,它总是打印GET。
如何发布表单,那么 的r.Method值为POST?
谢谢