am art this Error = mime: expected slash after first token
下面的一些详细信息。
目标是用户名和密码的登录表单可以从帖子中提取。
我还测试了一个卷曲帖子和静态HTML表格 ->同一问题= mime: expected slash after first token
GO代码的片段:
log.Printf("nnt[loginH()] - POST method ...n")
err := r.ParseForm()
if err != nil {
// Handle error here via logging and then return
DebugLog.Printf("[loginH()] - ERROR: with r.ParseForm. (err=%v)n", err)
log.Printf("[loginH()] - ERROR: with r.ParseForm. (err=%v)n", err)
}
username := r.Form["username"]
passwd := r.Form["passwd"]
log.Printf("[loginH()] - r.Form ... username=%s and passwd=%sn",username,passwd)
html/form是:
<form method="POST" action="/login">
<input type="text" name="username" placeholder="Email Address"/>
<input type="password" name="passwd" placeholder="Password"/>
<input type="submit" id="loginBtn" name="login" value="Logon"/>
</form>
输出是:
2016/12/15 21:36:07 [loginH()] - POST method ...
2016/12/15 21:36:07 [loginH()] - ERROR: with r.ParseForm. (err=mime: expected slash after first token)
2016/12/15 21:36:07 [loginH()] - r.Form ... username= and passwd=
事先感谢您的任何指示/信息/启蒙。
R.Form为空
此错误来自Mediatype.go的第85行。您可能会在内部从呼叫到parmediatype方法中遇到此错误。从那里看,您的静态形式或卷发似乎未正确设置内容类型或内容词的值。请检查这些标题是否有任何有问题的值。
来自文档:
// ParseMediaType parses a media type value and any optional
// parameters, per RFC 1521. Media types are the values in
// Content-Type and Content-Disposition headers (RFC 2183).
// On success, ParseMediaType returns the media type converted
// to lowercase and trimmed of white space and a non-nil map.
// The returned map, params, maps from the lowercase
// attribute to the attribute value with its case preserved.