两者的区别
- @Requestparam用来处理 Content-Type 为 application/x-www-form-urlencoded编码的内容
@Requestbody用来处理非 Content-Type: application/x-www-form-urlencoded编码格式的数据,比如:application/json、application/xml等类型的数据。 - 在GET请求中,不能使用@RequestBody。
在POST请求,可以使用@RequestBody和@RequestParam,但是如果使用@RequestBody,对于参数转化的配置必须统一。
如何传递参数:
把@RequestParam拼接到请求路径里,把@RequestBody对象用参数传递
editFormula(params, type) {
return axios.post(`/editIndicators?operatorType =${type}`, params, {
headers:{
'Content-Type': 'application/json',
accessToken: storage.getLocalValue('TOKEN_FINEREPORT') || '',
Authorization: storage.getLocalValue('Authorization') || ''
},
});
},