ArcGIS API for Javascript 二次开发。服务器用的tomcat。在调用服务的时候,由于一个服务是在另一台服务器上,读取服务的时候出现了跨域报错。
百度,两种方式:一个是程序前面添加Responese.Header.Add(“Accee-Crotrol-Allow-Origin”,”*”),这个我不知道在程序哪里添加,即使添加了也报错;一个实服务器端找到crossdomain.xml文件,修改,我的这个文件里,原本就有这句话,只是后面有个securte”false”。服务器不怎么设置。所以想别的方法。
搜到这个文章:http://www.gis520.com/thread-1799-1-1.html
这个是从Esri的角度来写解决方案。copy如下
“XMLHttpRequest cannot load http://server/arcgis/rest/info?f=json. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin错误解决方法:
文章内容主要是关于ArcGIS js Api v3.0版本报: XMLHttpRequest cannot load http://server/arcgis/rest/info?f=json. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin 的错误。
在esri中国社区中有同学提到:关于arcgis_js_api 3.0的问题,高手指教,在arcgis js api3.0中,在添加图层的时候浏览器开发者工具中会输出这个错误:XMLHttpRequest cannot load http://server/arcgis/rest/info?f=json. Origin http://localhost:8080 is not allowed by Acc