html 表单的 application/x-www-form-urlencoded 是默认值吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2436716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:29:23  来源:igfitidea点击:

is application/x-www-form-urlencoded default for html form?

htmlformsenctype

提问by Moon

I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencodedand multipart/form-data. I understand that I use multipart/form-datawhen I need to upload a file. When do I use application/x-www-form-urlencoded? Is it default form enctype?

我发现 HTML 表单只支持两种 enctype 类型。他们是application/x-www-form-urlencodedmultipart/form-data。我知道我multipart/form-data在需要上传文件时使用。我application/x-www-form-urlencoded什么时候使用?它是默认形式的enctype吗?

回答by BalusC

Yes, it is. Here's a cite from the W3 HTML forms specification:

是的。这是W3 HTML 表单规范中的引用:

The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data"should be used in combination with the INPUTelement, type="file".

此属性的默认值为"application/x-www-form-urlencoded"。该值"multipart/form-data"应与INPUT元素结合使用type="file"

The webbrowser will take care about URL encodingautomatically.

网络浏览器会自动处理URL 编码

回答by Moon

application/x-www-form-urlencoded

应用程序/x-www-form-urlencoded

This is the default content type. Forms submitted with this content type must be encoded as follows:

这是默认的内容类型。使用此内容类型提交的表单必须编码如下:

1) Control names and values are escaped. Space characters are replaced by '+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by '%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').

1) 控件名称和值被转义。空格字符被 '+' 替换,然后保留字符被转义,如 [RFC1738],第 2.2 节所述:非字母数字字符被替换为 '%HH',一个百分号和两个表示 ASCII 码的十六进制数字特点。换行符表示为“CR LF”对(即`%0D%0A')。

2) The control names/values are listed in the order they appear in the document. The name is separated from the value by '=' and name/value pairs are separated from each other by `&'.

2) 控件名称/值按它们在文档中出现的顺序列出。名称与值之间用“=”分隔,名称/值对用“&”分隔。

Check out thislink for more on form content types, or herefor more information about file uploads and such.

查看链接以获取有关表单内容类型的更多信息,或查看有关文件上传等的更多信息。

回答by Seth

Yes, the default enctypeis application/x-www-form-urlencoded.

是的,默认enctypeapplication/x-www-form-urlencoded