get请求方式:
func marixExplainPHandler(w http.ResponseWriter,rr *http.Request){
query := rr.URL.Query()
id := query.Get("id")
}
form表单传递参数
func marixExplainPHandler(w http.ResponseWriter,rr *http.Request){
con := rr.PostFormValue("con")
lang := rr.PostFormValue("lang")
}
post请求正常接收参数:
func marixExplainPHandler(w http.ResponseWriter,request *http.Request){
decoder := json.NewDecoder(request.Body)
// 用于存放参数key=value数据
var params map[string]string
// 解析参数 存入map
decoder.Decode(¶ms)
fmt.Printf("POST json: username=%s, password=%s
", params["username"], params["password"])
}