-2
如何从GO中的服务器接收值?我的意思是在PHP中使用$_POST['value']
或$_GET['value']
。如何通过GO接收来自服务器的值?
如何从GO中的服务器接收值?我的意思是在PHP中使用$_POST['value']
或$_GET['value']
。如何通过GO接收来自服务器的值?
阅读https://golang.org/pkg/net/http/#Request 下面是一个获取表单提交值的快速示例。
package main
import (
"io"
"net/http"
"log"
)
func GetValue(w http.ResponseWriter, req *http.Request) {
val := req.FormValue("value")
io.WriteString(w, val + "\n")
}
func main() {
http.HandleFunc("/hello", GetValue)
log.Fatal(http.ListenAndServe(":12345", nil))
}
so why this does not work?这个C++代码发送值但失败: – Mehhh
@no_ideaw您错过了C++代码,但是如果您发布了在问题中使用的所有代码,以便我们可以看到可能出现错误的位置,则会更容易。 – Topo
请参阅下面的C++代码的答案;它太长了,所以我发布了它的答案 – Mehhh