No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is there
2017-03-28 16:45
603 查看
1、原因:这个和安全机制有关,默认不允许跨域调用
2、解决方法:
加上了上面代码之后若还是报上面的错误,则可能是后端Controller层的访问路径不可以访问。可能是访问方法不支持,比如不支持GET,
也有可能是被拦截器拦截不能直接访问(这个问题实际遇到过)。
2、解决方法:
在controller中添加如下代码: response.setHeader("Access-Control-Allow-Origin", "*"); 只是临时用,据说不安全。
加上了上面代码之后若还是报上面的错误,则可能是后端Controller层的访问路径不可以访问。可能是访问方法不支持,比如不支持GET,
也有可能是被拦截器拦截不能直接访问(这个问题实际遇到过)。
相关文章推荐
- ajax跨域请求:No 'Access-Control-Allow-Origin' header is present on the requested resource
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource”
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
- ajax跨域(No 'Access-Control-Allow-Origin' header is present on the requested resource)
- js跨域访问,no 'access-control-allow-origin' header is present on the requested resource
- jquery ajax No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore no
- 解决Vue请求 ‘No 'Access-Control-Allow-Origin' header is present on the requested resource’错误
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- 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.'Ajax跨域访问解决方案
- 本地Ajax跨域访问 No 'Access-Control-Allow-Origin' header is present on the requested resource.
- 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.”
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- No 'Access-Control-Allow-Origin' header is present on the requested resource.
- JS跨域:No 'Access-Control-Allow-Origin' header is present on the requested resource
- No 'Access-Control-Allow-Origin' header is present on the requested resource.
- No 'Access-Control-Allow-Origin' header is present on the requested resource.