office文件所对应的的 Content-type类型Content-type类型总结

1.office文件所对应的的 Content-type类型

后缀 MIME Type
.doc application/msword
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/vnd.ms-word.document.macroEnabled.12
.dotm application/vnd.ms-word.template.macroEnabled.12
.xls application/vnd.ms-excel
.xlt application/vnd.ms-excel
.xla application/vnd.ms-excel
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xlsm application/vnd.ms-excel.sheet.macroEnabled.12
.xltm application/vnd.ms-excel.template.macroEnabled.12
.xlam application/vnd.ms-excel.addin.macroEnabled.12
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
.ppt application/vnd.ms-powerpoint
.pot application/vnd.ms-powerpoint
.pps application/vnd.ms-powerpoint
.ppa application/vnd.ms-powerpoint
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.ppam application/vnd.ms-powerpoint.addin.macroEnabled.12
.pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.potm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.ppsm application/vnd.ms-powerpoint.slideshow.macroEnabled.12

2.什么是 Content-type

Content-type是实体首部字段,用于说明请求或返回的消息是用什么格式进行编码的,在request header和response header里都有存在。 用来向服务器或者浏览器说明传输的文件格式,以便服务器和浏览器按照正确的格式进行解析。在最初的的http post请求只支持application/x-www-form-urlencoded,参数是通过浏览器的url进行传递,但此种方法不支持文件上传,所以后来Content-type 扩充了multipart/form-data类型以支持向服务器发送二进制数据,以及随着后面web应用的日益发展增加了application/json的类型

3.几种常见类型

1:application/x-www-form-urlencoded
form表单提交的默认值,传输数据都是以key=value(key1=val1&key2=val2)格式进行编码,并且key和value都进行了编码(Content-Type: application/x-www-form-urlencoded;charset=utf-8
name=%E9%BB%84%E6%99%93%E6%98%8E&age=40)

2:multipart/form-data
指定传输数据为二进制数据,专门用于传输文件,例如图片、mp3、文件等,在文件、图片等上传的时候要设置request的content-type 为multipart/form-data类型

3:application/json
此类型告诉服务端数据是序列化的json字符串,由于json规范的流行和越来越多的浏览器支持原生JSON.stringfy,此类型也越来越多的被使用。
(最后发送到服务端的数据格式eg:"{‘name’:‘张三’,‘age’:‘40’}")

另外还有
application/xhtml+xml :XHTML格式
application/xml : XML数据格式
application/atom+xml :Atom XML聚合格式
application/json : JSON数据格式
application/pdf :pdf格式
application/msword : Word文档格式
application/octet-stream : 二进制流数据(如常见的文件下载)
…等等

链接:https://www.jianshu.com/p/4b09c260f9b2

你可能感兴趣的:(http,java,java,http,Content-type)