2 回答

TA貢獻(xiàn)1887條經(jīng)驗 獲得超5個贊
我想你有一個http.Request. 假設(shè)它被稱為hr。
然后你可以做
hr.ParseForm()
之后你可以使用hr.Formwhich 定義如下:
// Form contains the parsed form data, including both the URL
// field's query parameters and the POST or PUT form data.
// This field is only available after ParseForm is called.
// The HTTP client ignores Form and uses Body instead.
Form url.Values
url.Values地圖在哪里:
type Values map[string][]string
這是使用解析形式的示例,其中我只對給定 name 的第一個值感興趣:
func getFormValue(hr *http.Request, name string) string {
if values := hr.Form[name]; len(values) > 0 {
return values[0]
}
return ""
}
- 2 回答
- 0 關(guān)注
- 302 瀏覽
添加回答
舉報