Action With Axios

weixin_34007886發表於2017-08-19

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為什麼不用JQueryajax呢……

相關文章