:9528/#/students/index:1 Access to XMLHttpRequest at 'http://localhost:8080/javaWeb_war_exploded/getAllStudents.action' from origin 'http://localhost:9528' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. index.vue?6ced:35 Error: Network Error at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16) at XMLHttpRequest.handleError (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:69) :8080/javaWeb_war_exploded/getAllStudents.action:1 Failed to load resource: net::ERR_FAILED
时间: 2023-07-11 20:54:03 浏览: 179
这是一个关于跨域请求的错误。当一个网站在浏览器中请求另一个域名下的资源时,浏览器会发送一个跨域请求。而出于安全考虑,浏览器会限制跨域请求的访问权限,只有在服务器端配置了相关的跨域访问策略才能正常访问。在这个错误中,服务器端没有配置允许该网站访问的策略,所以浏览器会拒绝访问。需要在服务器端配置相关的策略,或者使用代理等方式来解决。
相关问题
:9528/#/students/index:1 Access to XMLHttpRequest at 'http://localhost:8080/javaWeb_war_exploded/getAllStudents.action' from origin 'http://localhost:9528' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. index.vue?6ced:44 Error: Network Error at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16) at XMLHttpRequest.handleError (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:69) :8080/javaWeb_war_exploded/getAllStudents.action:1 Failed to load resource: net::ERR_FAILED
这是一个跨域请求的错误,由于浏览器的安全策略,不同域名之间的请求是被禁止的。要解决这个问题,需要在服务器端设置CORS(跨域资源共享)策略,允许请求的来源。如果你是使用Java Web开发,可以在响应头中添加Access-Control-Allow-Origin字段,将其值设置为请求的源头。例如,如果你的请求源头是http://localhost:9528,响应头应该包含:Access-Control-Allow-Origin: http://localhost:9528。这样浏览器就会允许跨域请求了。
阅读全文