Accept http request parameters and distinguishing Content-Type

Accept request header belongs, is described in response to body type data the client wishes to receive.
Content-Type header entity belongs, the type of data described body sent by the client.
For example:
the Accept: text / xml; 
the Content-the Type: text / HTML 
desired type of the received data is in xml format, the data format of the data transmitted this request is html.
Common media format types are as follows:
    text / HTML: HTML format
    text / plain: plain text format      
    text / xml: XML format
    image / gif: gif image format    
    image / jpeg: jpg image format 
    image / png: png image format
begins with application media format type:
   file application / XHTML + XML: XHTML format
   application / xml: XML data format
   application / atom + xml: Atom XML syndication format    
   application / json: JSON data format
   application / pdf: pdf format  
   application / msword: Word document format
   application / octet-stream: a binary stream of data (such as the common file download)
   file application / X-WWW-form-urlencoded: <form encType = ""> the default encType, form form data is encoded as a key / value format sent to the server (the default format of the data submission form)
Another common media format is used when uploading documents:
    multipart / form-the data: when the need for file upload in a form, you need to use this format.
Frequently Asked Questions
1, * / * role?
"Accept", "image / gif , image / jpeg, image / pjpeg, image / pjpeg, application / x-shockwave-flash, application / xaml + xml, application / vnd.ms-xpsdocument, application / x-ms-xbap , application / x-ms-application , application / vnd.ms-excel, application / vnd.ms-powerpoint, application / msword, * / * ", a large segment resources, has added in the last * / *, which Why?
Client support these types, and specify the type of priority hope, if not, turn the expression of the will!
2, how to achieve the server side?
SpringMvc, for example, offers a variety of MessageConverter, users can expand their achieve
various MessageConverter frame start time, will be able to support the load
When the request, based on the set of local order to find out whether a corresponding MessageConverter, if MessageConverter return to use found for the corresponding type data.

Reproduced in: https: //my.oschina.net/artong999/blog/3058556

Guess you like

Origin blog.csdn.net/weixin_33782386/article/details/92042690