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

报错:跨域

 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="*">
 
posted @ 2016-07-05 09:11  NAYNEHC  阅读(847)  评论(0编辑  收藏  举报