Access to XMLHttpRequest at ‘http://localhost:8001 springBoot + vue请求显示跨域问题, |
您所在的位置:网站首页 › 多米诺骨牌视频素材 › Access to XMLHttpRequest at ‘http://localhost:8001 springBoot + vue请求显示跨域问题, |
Access to XMLHttpRequest at 'http://localhost:8001/****/****/download' from origin 'http://localhost:9528' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
后端没问题,可以显示查询出来的信息。 /** * 导出所有学生信息 * 通过Excel导出 */ @GetMapping("/****/****") public void download(HttpServletResponse response){ tbSchoolService.download(response); }原因:由于设置了权限框架,该axios请求被拦截。造成跨域的问题 解决方法:设置请求头 在request.js 文件设置
请求方法,添加 getToken() studentApi.downloadStudent(getToken()).then(res => {}后端几乎不用修改 请求结果: |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |