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

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

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

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

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

 
   <filter>
        <filter-name>cross-originfilter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilterfilter-class>
       <init-param>
           <param-name>chainPreflightparam-name>
           <param-value>falseparam-value>
       init-param>
       <init-param>
           <param-name>allowedOriginsparam-name>
           <param-value>*param-value>
       init-param>
       <init-param>
           <param-name>allowedMethodsparam-name>
           <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONSparam-value>
       init-param>
       <init-param>
           <param-name>allowedHeadersparam-name>
           <param-value>*param-value>
       init-param>
    filter>
    
    
    
    <filter-mapping>
        <filter-name>cross-originfilter-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目录,再次重启即可

你可能感兴趣的:(GeoServer 2.15.0版本跨域问题解决方法)