spring 解決跨域 web.xml添加

<!--CORS 跨域資源訪問-->
   <filter>
       <filter-name>CORS</filter-name>
       <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
       <init-param>
           <param-name>cors.allowGenericHttpRequests</param-name>
           <param-value>true</param-value>
       </init-param>
       <init-param>
           <param-name>cors.allowOrigin</param-name>
           <param-value>*</param-value>
       </init-param>
       <init-param>
           <param-name>cors.allowSubdomains</param-name>
           <param-value>false</param-value>
       </init-param>
       <init-param>
           <param-name>cors.supportedMethods</param-name>
           <param-value>GET, HEAD, POST, OPTIONS</param-value>
       </init-param>
       <init-param>
           <param-name>cors.supportedHeaders</param-name>
           <param-value>*</param-value>
       </init-param>
       <init-param>
           <param-name>cors.exposedHeaders</param-name>
           <param-value>X-Test-1, X-Test-2</param-value>
       </init-param>
       <init-param>
           <param-name>cors.supportsCredentials</param-name>
           <param-value>true</param-value>
       </init-param>
       <init-param>
           <param-name>cors.maxAge</param-name>
           <param-value>3600</param-value>
       </init-param>
   </filter>
   <filter-mapping>
       <filter-name>CORS</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>
相關文章
相關標籤/搜索