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