vue中axios中post跨域SpringBoot获取不到RequestBody数据

目前使用axios实现vue中与后台数据交互,目前GET,DELETE都是正常使用,但是会有跨域的问题,我就是临时在返回头加上了Access-Control-Allow-Origin:”*”

但是一直由于POST提交数据后台数据一直获取不到RequestBody,我之前使用postman测试都是可以通过的,显示status failure后台也根本不报错,因为获取不到

开始是以为是我格式问题换了几种数据

axios.post('http://localhost:8080/xxx/model/' + path, modelIds).then(response = > {this.searchContent()
}).catch(function (error) {
    console.log(error);
});
axios.post('http://localhost:8080/xxx/process/model/27501', {
    comment: 'Fred',
    userName: 'Flintstone'
}).then(function (response) {
    console.log(response);
}).catch(function (error) {
    console.log(error);
});

const options = {
    method: 'POST',
    headers: {'content-type': 'application/json'},
    data: modelIds,
    url: 'http://localhost:8080/xxx/model/' + path
};
axios(options)

还有就是PUT提交时 application/x-www-form-urlencoded,后台用RequestParam,或者不写都可以接受,对象的话要set,get方法,我刚开始用的form-data,SpringBoot是获取不到数据的

我目前用的是nginx,代理


版权声明:本文为qq_26341515原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。