天天看點

Springboot中@RequestParam和@requestbody的差別

@RequestParam

用來處理請求頭Content-Type: 為

application/x-www-form-urlencoded編碼的内容。(Http協定中,如果不指定Content-Type,則預設傳遞的參數就是application/x-www-form-urlencoded類型)

@RequestBody

用來處理請求頭Content-Type: 為

application/json編碼的内容,明确的告訴伺服器發送的内容是json。因為需要讀取body中内容,是以隻能接受post請求。

具體看這篇博文

添加連結描述