其他分享
首页 > 其他分享> > GeoServer 2.15.0版本跨域问题解决方法

GeoServer 2.15.0版本跨域问题解决方法

作者:互联网

geoserver默认不开启跨域设置,开启步骤如下:

1、修改配置文件web.xml,该配置文件的路径如下

\webapps\geoserver\WEB-INF\web.xml

2、搜索:cross-origin,将注释的部分解注。

 <!-- Uncomment following filter to enable CORS -->
   <filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
       <init-param>
           <param-name>chainPreflight</param-name>
           <param-value>false</param-value>
       </init-param>
       <init-param>
           <param-name>allowedOrigins</param-name>
           <param-value>*</param-value>
       </init-param>
       <init-param>
           <param-name>allowedMethods</param-name>
           <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
       </init-param>
       <init-param>
           <param-name>allowedHeaders</param-name>
           <param-value>*</param-value>
       </init-param>
    </filter>
    
    
    <!-- Uncomment following filter to enable CORS  -->
    <filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

3、下载 jetty-servlets jar包,2.15.0对应的版本是 jetty-servlets-9.4.12.v20180830.jar,放在

\geoserver\WEB-INF\lib

4、重启geoserver,如果报错,再下载对应 jetty-http 和 jetty-util jar包,放在lib目录,再次重启即可

标签:origin,跨域,servlets,GeoServer,jar,jetty,cross,geoserver,2.15
来源: https://www.cnblogs.com/yangzhengier/p/12072743.html