什么是默认的表单 HTTP 方法?

2022-01-30 00:00:00 forms html

When an HTML form is submitted without specifying a method, what is the default HTTP method used? GET or POST?

Has this behaviour ever changed between HTML standards?

Please cite a W3C standard document if possible.

解决方案

It's GET.

Take a look W3C Superceded Recommendation 17.3 The FORM element.

Excerpt:

<!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 --
  >

Good read

Methods GET and POST in HTML forms - what's the difference?

相关文章