@requestmapping注解 requestbody和requestparam區(qū)別?
requestbody和requestparam區(qū)別?Requestbody處理httpentity傳遞的數據,通常用于處理非內容類型的數據:application/x-www-form-urlenc
requestbody和requestparam區(qū)別?
Requestbody
處理httpentity傳遞的數據,通常用于處理非內容類型的數據:application/x-www-form-urlencoded格式。
在get請求中,@requestbody不適用,因為沒有httpentity。
在post請求中,通過httpentity傳遞的參數必須在請求頭中聲明數據類型content type。Spring MVC使用由
handleradapter配置的httpmessage轉換器解析httpentity中的數據,然后將其綁定到相應的bean。
Requestparam
用于處理內容類型:content encoded for application/x-www-form-urlencoded。(在HTTP協(xié)議中,如果未指定內容類型,則默認情況下傳遞的參數是application/x-www-form-urlencoded的類型。)