前端Http请求中的Content-Type
Content-Type用来表示请求中发送中数据类型信息
Content-Type的格式为:type/subtype(;parameter)? type
type:表示主类型,可以是任意的字符串,如text。
subtype:表示子类型,如html。
parameter:表示参数,可写可不写。如Accept请求头的参数,常见的有charset=‘utf-8’.
例如:Content-Type:text/html;charset:utf-8;
Content-Type中常见的格式类型:
1、以text开头的媒体格式类型:
text/html:HTML格式。
text/plain:纯文本格式。
text/xml:XML格式。
2、以image开头 的格式类型:
image/gif、image/png、image/jpeg
3、以application开头的格式类型:
application/xhtml+xml :XHTML格式。
application/xml :XML数据格式。
application/atom+xml:Atom SML聚合格式。
application/json:JSON数据格式。
application/pdf:pdf格式。
application/msword:Word文档格式。
application/octet-stream:二进制流数据,如
application/x-www-from-urlencoded:中默认的encType,form表单数据被编码为key/value格式发送到服务器(表单默认的提交数据的格式)
4、以multipart开头的格式类型:
multipart/form-data:上传文件(如Excel)就使用该格式