在未指定方法的情况下提交HTML表单时,使用的默认HTTP方法是什么?GET还是POST?
这种行为是否在HTML标准之间发生了变化?
如果可能,请引用W3C标准文档.
Dre*_*lls 164
这是GET.
看看这里.
摘抄:
<!ATTLIST FORM
%attrs; -- %coreattrs, %i18n, %events --
action %URI; #REQUIRED -- server-side form handler --
method (GET|POST) GET -- HTTP method used to submit the form--
enctype %ContentType; "application/x-www-form-urlencoded"
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --
name CDATA #IMPLIED -- name of form for scripting --
onsubmit %Script; #IMPLIED -- the form was submitted --
onreset %Script; #IMPLIED -- the form was reset --
accept-charset %Charsets; #IMPLIED -- list of supported charsets --
>
Run Code Online (Sandbox Code Playgroud)
好读
如果未指定,则默认为GET.我没有看到这种行为有任何不同的迹象.并且GET是默认值是有道理的,因为它指定该方法应该用于没有副作用的动作.
http://www.faqs.org/faqs/www/cgi-faq/section-37.html
来自http://www.w3.org/TR/html401/interact/forms.html#h-17.3的引文:
method = get | post [CI]
此属性指定将使用哪种HTTP方法提交表单数据集.可能的(不区分大小写)值是"get
"(默认值)和"post
".有关使用信息,请参阅表单提交部分.17.13.1表单提交方法元素
的方法属性FORM
指定用于将表单发送到处理代理程序的HTTP方法.此属性可能包含两个值:
get:使用HTTP"get"方法,将表单数据集附加到action属性指定的URI(带有问号("?")作为分隔符),并将此新URI发送到处理代理程序.
post:使用HTTP"post"方法,表单数据集包含在表单主体中并发送给处理代理程序.
当表单是幂等的(即,不会产生副作用)时,应使用"get"方法.许多数据库搜索没有明显的副作用,并为"get"方法提供理想的应用程序.
小智 7
(更完整的答案,也关于操作和 enctype)
\n\nHTML 表单的默认“method”、“action”和“enctype”,如果未指定,则分别为
GET 、当前 URL 和application/x-www-form-urlencoded
。
(即,默认情况下,表单使用输入的参数请求当前页面。)
除了“action”(在 HTML 4 中这是必需的)之外,此行为从未改变。引用:
\n\nmethod: “ method 属性的默认缺失值是... GET 状态。”
\n行动:
\n\n\n元素的操作是元素\xe2\x80\x99s formaction属性的值(如果该元素是提交按钮并且具有这样的属性),或者是其表单所有者\xe2\x80\x99s操作属性的值,如果它有一个,否则为空字符串。<...> 如果action为空字符串,则设action为表单文档的document\xe2\x80\x99s URL。
\n
enctype:“ enctype 属性的默认缺失值application/x-www-form-urlencoded
是……状态。”
method: "可能的(不区分大小写)值是 \'get\' (默认值)和 \'post\'。"\n
\naction: 无默认值,DTD 需要它
\nenctype: "此属性的默认值是\'application/x-www-form-urlencoded\'。”
<!ATTLIST FORM\n %attrs; -- %coreattrs, %i18n, %events --\n action %URI; #REQUIRED -- server-side form handler --\n method (GET|POST) GET -- HTTP method used to submit the form--\n enctype %ContentType; "application/x-www-form-urlencoded"\n
Run Code Online (Sandbox Code Playgroud)\n\nmethod: "可以是 GET 或 POST,默认为 GET。"
\naction:没有明确的句子,仅在 DTD 中
\nenctype:“它默认为application/x-www-form-urlencoded。”
<!ATTLIST FORM\n action %URL #IMPLIED -- server-side form handler --\n method (%HTTP-Method) GET -- see HTTP specification --\n enctype %Content-Type; "application/x-www-form-urlencoded"\n
Run Code Online (Sandbox Code Playgroud)\n\n方法:没有明确的句子,仅在 DTD 中
\naction: "表单的操作 URI 默认为文档的基本 URI"
\nenctype: "所有表单的默认编码是 `application/x-www-form-urlencoded\ '。”
<!ATTLIST FORM\n ACTION CDATA #IMPLIED\n METHOD (%HTTP-Method) GET\n ENCTYPE %Content-Type; "application/x-www-form-urlencoded"\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
83155 次 |
最近记录: |