为了实现跨域进行cors而导致的问题

0 投票

先前为了实现跨域,进行对iserver的web.xml进行设置,

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
   version="3.0"> 
  




<filter>
       <filter-name>CORS</filter-name>
       <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
       <init-param>
        <param-name>cors.allowOrigin</param-name>
           <param-value>*</param-value>
       </init-param>
       <init-param>
        <param-name>cors.supportedMethods</param-name>
           <param-value>GET, POST, HEAD, PUT, DELETE</param-value>
       </init-param>
       <init-param>
        <param-name>cors.supportedHeaders</param-name>
           <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value>
       </init-param>
       <init-param>
           <param-name>cors.exposedHeaders</param-name>
           <param-value>Set-Cookie</param-value>
       </init-param>
       <init-param>
           <param-name>cors.supportsCredentials</param-name>
           <param-value>true</param-value>
       </init-param>
   </filter>

   <filter-mapping>
       <filter-name>CORS</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>



<display-name>SuperMap iServer 8C</display-name>			

<filter>
    <filter-name>iserver-services</filter-name> 
    <filter-class>com.supermap.server.host.webapp.ApplicationFilter</filter-class>
	<async-supported>true</async-supported>
  </filter>
  <filter-mapping>
    <filter-name>iserver-services</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
        <welcome-file>index.htm</welcome-file>
  </welcome-file-list>


</web-app>


然后一些跨域的访问可以成功进行,有一些本来不需要cors跨域的却不能实现了

请问哪里出问题了

7月 25, 2017 分类:  1252次浏览 | 用户: Zzombie 才疏学浅 (12 分)

1个回答

0 投票
 
已采纳

没看出怎么跨的域,建议不修改web.xml通过iServer的配置文件进行配置,帮助文档地址:
http://support.supermap.com.cn:8090/iserver/help/html/Server_Service_Management/GISService_Config/Service_Config/Config_Interface/interface_config.htm

该资源默认允许跨域的,我这边未重现问题。

从报错看是响应头有两个allow-origin, http://localhost:8080 和 * ,你的请求满足其中一个(*),但是不满足另一个所以报错跨域。

7月 25, 2017 用户: 毛瑞 名扬四海 (1,780 分)
采纳于 7月 25, 2017 用户:Zzombie
...