美文网首页开源GISGIS文章集
OpenLayer4跨域访问GeoServer发布的TMS服务

OpenLayer4跨域访问GeoServer发布的TMS服务

作者: 忘我怎么解 | 来源:发表于2018-02-02 14:00 被阅读60次

    在geoserver中WEB-INF文件夹下,修改web.xml文件,添加过滤器内容,如下:

          <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>
          <init-param>
            <param-name>cors.allowed.methods</param-name>
            <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
          </init-param>
          <init-param>
            <param-name>cors.allowed.headers</param-name>
            <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
          </init-param>
          <init-param>
            <param-name>cors.exposed.headers</param-name>
            <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
          </init-param>
          <init-param>
            <param-name>cors.support.credentials</param-name>
            <param-value>true</param-value>
          </init-param>
          <init-param>
            <param-name>cors.preflight.maxage</param-name>
            <param-value>10</param-value>
          </init-param>
        </filter>
        <filter-mapping>
          <filter-name>CorsFilter</filter-name>
          <url-pattern>/*</url-pattern>
        </filter-mapping>
    

    修改完成保存,重新启动Tomcat即可跨域访问。

    相关文章

      网友评论

        本文标题:OpenLayer4跨域访问GeoServer发布的TMS服务

        本文链接:https://www.haomeiwen.com/subject/qlxezxtx.html