: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
时间: 2023-07-11 22:53:43 浏览: 97
这是一个跨域请求的错误,由于浏览器的安全策略,不同域名之间的请求是被禁止的。要解决这个问题,需要在服务器端设置CORS(跨域资源共享)策略,允许请求的来源。如果你是使用Java Web开发,可以在响应头中添加Access-Control-Allow-Origin字段,将其值设置为请求的源头。例如,如果你的请求源头是http://localhost:9528,响应头应该包含:Access-Control-Allow-Origin: http://localhost:9528。这样浏览器就会允许跨域请求了。
相关问题
: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
这是一个关于跨域请求的错误。当一个网站在浏览器中请求另一个域名下的资源时,浏览器会发送一个跨域请求。而出于安全考虑,浏览器会限制跨域请求的访问权限,只有在服务器端配置了相关的跨域访问策略才能正常访问。在这个错误中,服务器端没有配置允许该网站访问的策略,所以浏览器会拒绝访问。需要在服务器端配置相关的策略,或者使用代理等方式来解决。
http://localhost:8080/#/
回答: 根据提供的引用内容,http://localhost:8080/#/ 是一个网址,它是用来访问部署在Tomcat服务器上的项目的。在部署项目之前,需要先修改配置并保存,然后将项目部署到Tomcat安装目录下的webapp文件夹中。接着重启Tomcat服务器,就可以通过访问http://localhost:8080来正常访问项目了。\[1\]然而,有时候在前后端分离的情况下,当Vue调用SpringBoot方法时,可能会出现跨域错误。这是因为浏览器的同源策略限制了浏览器执行其他网站的脚本。解决这个问题可以通过在后端添加'Access-Control-Allow-Origin'头来允许跨域访问。\[2\]此外,如果在浏览器输入http://localhost:8080之前没有启动Tomcat服务器,那么页面将无法打开。因此,在访问该网址之前,确保Tomcat服务器已经启动并且保持运行状态。\[3\]
#### 引用[.reference_title]
- *1* *3* [Tomat安装之后http://localhost:8080无法访问最全解决方案](https://blog.csdn.net/vagatable_XX/article/details/121580764)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [跨域Access to XMLHttpRequest at ‘http://localhost:8181/list‘ from origin ‘http://localhost:8080...](https://blog.csdn.net/weixin_43768573/article/details/128367108)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]