No 'Access-Control-Allow-Origin' header is present on the requested resource
Posted 一沙世界
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No 'Access-Control-Allow-Origin' header is present on the requested resource相关的知识,希望对你有一定的参考价值。
一、现象
ajax调用请求后,前端提示收到这个错误
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
二、原因
这是一个典型的跨域请求失败的例子。
三、解决
服务器的响应消息中增加头字段即可。
rsp.addHeader("Access-Control-Allow-Origin", "*");
四、扩展
更多的关于CORS的内容可以学习这篇文章:
https://yq.aliyun.com/articles/69313
以上是关于No 'Access-Control-Allow-Origin' header is present on the requested resource的主要内容,如果未能解决你的问题,请参考以下文章
Jenkins打包报错:(No such file or directory) and 'parent.relativePath' points at no local POM
VS Code报错Module 'xx' has no 'xx' member pylint(no-member)解决办法
VSCODE 报错 Module ‘xx‘ has no ‘xx‘ member pylint(no-member)
VSCODE 报错 Module ‘xx‘ has no ‘xx‘ member pylint(no-member)