1、一定要在init方法里调用,代码如下
OpenLayers.ProxyHost = '/CERPGIS/cgi/proxy.cgi?url=';//代理
2、proxy.cgi配置
allowedHosts = ['www.openlayers.org', 'openlayers.org',
'labs.metacarta.com', 'world.freemap.in',
'prototype.openmnnd.org', 'geo.openplans.org',
'sigma.openplans.org', 'demo.opengeo.org',
'www.openstreetmap.org', 'sample.azavea.com',
'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080',
'vmap0.tiles.osgeo.org', 'www.openrouteservice.org',
'172.31.170.98:8088','localhost:8080']
注意上面最后一行的ip地址配置是你要访问的服务器地址 ,设置为允许访问
3、在tomcat的conf文件下的content.xml里配置
<Context privileged="true">
开放cgi serverlet权限
4、修改web.xml时注意python设置
<init-param>
<param-name>executable</param-name>
<!--此处需要安装python-->
<param-value>D:/Python27/ArcGIS10.2/python.exe</param-value>
</init-param>
设置python路径,注意python环境变量