栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

CORS-Tomcat-Geoserver

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CORS-Tomcat-Geoserver

我需要做同样的事情,以避免在OpenLayers中使用代理。

由于我正在运行Ubuntu 12.04,因此我已经安装了 Tomcat 7.0.55 ,而不是默认的7.0.26(从软件包安装)。

要添加CORS标头,我仅添加

$CATALINA_HOME/conf/web.xml
了以下几行:

<filter>  <filter-name>CorsFilter</filter-name>  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>  <init-param>    <param-name>cors.allowed.origins</param-name>    <param-value>*</param-value>  </init-param></filter><filter-mapping>  <filter-name>CorsFilter</filter-name>  <url-pattern>/*</url-pattern></filter-mapping>

然后重新启动tomcat。

例如,当我尝试从Geoserver中获取

http://development.localhost.lan/geoserver/wfs
运行中的应用程序的URL时,将
http://localhost:3000
获得以下标头:

请求的标头:

POST /geoserver/wfs HTTP/1.1Host: development.localhost.lanOrigin: http://localhost:3000X-Requested-With: XMLHttpRequest(...)

响应头:

Access-Control-Allow-Credentials:trueAccess-Control-Allow-Origin:http://localhost:3000Connection:Keep-AliveContent-Disposition:inline; filename=geoserver-GetFeature.textContent-Encoding:gzipContent-Length:469Content-Type:text/xml; subtype=gml/3.1.1Date:Tue, 29 Jul 2014 21:31:08 GMTKeep-Alive:timeout=5, max=100Server:Apache-Coyote/1.1

该版本适用于Chrome(版本35.0.1916.153)和Firefox(版本31.0)。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/430560.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号