您的位置:首页 > 理论基础 > 计算机网络

XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.

2016-07-05 09:11 621 查看
报错:跨域

XMLHttpRequest cannot load http://localhost:8080/admin/admin/store. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
http://xxx:8088' is therefore not allowed access.
网上查了查有两种解决方法
在测试的时候是别的地址来访问的,所以在获取session的时候,把地址改成 http:/xxx:8088/.....(因为我的是在上传文件的时候需要使用到)
解决办法:
1.页面请求的是自己写的一个servelet,加入response.setHeader("Access-Control-Allow-Origin", "*");
2.请求页面html,加入<meta http-equiv="Access-Control-Allow-Origin" content="*">
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: