Geoserver 2.18.0 解决跨域

本文详细介绍了如何解决Geoserver 2.18.0的跨域问题,包括从geoserver的lib目录复制jetty-servlets和jetty-util的jar包到特定位置,以及在web.xml文件中进行关键的配置修改来启用跨域支持。
摘要由CSDN通过智能技术生成

一、去geoserve的lib目录下 geoserver\lib找jetty-servlets-XX.jar , jetty-util-xx.jar(xx表示不同的版本)两个jar包;

二、把两个jar包拷贝到geoserver\webapps\geoserver\WEB-INF\lib\目录下;

三、去geoserver\webapps\geoserver\WEB-INF目录下找web.xml,进行如下修改:

1.去掉代码段的注释 geoserver 默认的跨域配置

<filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
        <init-param>
            <param-name>allowedOrigins</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>allowedMethods</param-name>
            <param-value>GET,POST</param-value>
        </init-param>
        <init-param>
            <param-name>allowedHeaders</param-name>
            <param-value>x-requested-with,content-type</param-value>
        </init-param>
    </filter>

2.去找的平级标签,去掉注释,以下内容:

<filter-mapping>
    <filter-name>cross-origin</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping>

3.完整web.xml代码段

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>GeoServer</display-name>
  
      <context-param>
    <param-name>serviceStrategy</param-name>
    <!-- Meaning of the different values :
         
         PARTIAL-BUFFER2
         - Partially buffers the first xKb to disk. Once that has buffered, the the 
           result is streamed to the user. This will allow for most errors to be caught
           early. 
           
         BUFFER
         - stores the entire response in memory first, before sending it off to
           the user (may run out of memory)

         SPEED
         - outputs directly to the response (and cannot recover in the case of an
           error)

         FILE
         - outputs to the local filesystem first, before sending it off to the user
      -->
    <param-value>PARTIAL-BUFFER2</param-value>
  </context-param>
  
  <context-param>
    <!-- see comments on the PARTIAL-BUFFER strategy -->
    <!-- this sets the size of the buffer.  default is "50" = 50kb -->

    <param-name>PARTIAL_BUFFER_STRATEGY_SIZE</param-name>
    <param-value>50</param-value>
  </context-param>
  
  <!--Can be true or false (defaults to: false). -->
  <!--When true the JSONP (text/javascript) output format is enabled -->
  <!--
  <context-param>
    <param-name>ENABLE_JSONP</param-name>
    <param-value>true</param-value>
  </co
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值