Spring端设置请求@ResponseBody
时,Axios如何正确发送请求体?
const body = {};
axios.post('url',body)
.then()
.catch()
其他方式均不行
Using application/x-www-form-urlencoded format
By default, axios serializes JavaScript objects to JSON. To send data in the application/x-www-form-urlencoded format instead, you can use one of the following options.
使用Axios传参时,传统的后端Spring MVC是无法获取到参数的
var qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 }));
了解更多 Axios Readme
呃,非webpack的项目怎么require('qs')
?非webpack为什么不用JQuery
的ajax
呢……