2017-05-03 37 views

回答

2

阅读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)) 
} 
+0

so why this does not work?这个C++代码发送值但失败: – Mehhh

+0

@no_ideaw您错过了C++代码,但是如果您发布了在问题中使用的所有代码,以便我们可以看到可能出现错误的位置,则会更容易。 – Topo

+0

请参阅下面的C++代码的答案;它太长了,所以我发布了它的答案 – Mehhh

相关问题