Get
- @Query
- @QueryMap
- Query集合
- @Path
Post
- @field
- @FieldMap
@Body
上傳
Multipart
常用的編碼方式
form的enctype屬性爲編碼方式,常用有兩種:application/x-www-form-urlencoded和multipart/form-data,默認爲application/x-www-form-urlencoded。
x-www-form-urlencoded
當action爲get時候,瀏覽器用x-www-form-urlencoded的編碼方式把form數據轉換成一個字串(name1=value1&name2=value2…),然後把這個字串append到url後面,用?分割,加載這個新的url。
multipart/form-data
當action爲post時候,瀏覽器把form數據封裝到http body中,然後發送到server。 如果沒有type=file的控件,用默認的application/x-www-form-urlencoded就可以了。 但是如果有type=file的話,就要用到multipart/form-data了。瀏覽器會把整個表單以控件爲單位分割,併爲每個部分加上Content-Disposition(form-data或者file),Content-Type(默認爲text/plain),name(控件name)等信息,並加上分割符(boundary)。
參考:http://duanyytop.github.io/2016/08/06/Retrofit%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/