zoukankan      html  css  js  c++  java
  • Tomcat 6 跨域的支持

    1.添加2个jar包 这个我是自己保存在云端的 

    cors-filter-1.7.jar

    java-property-utils-1.9.jar

    tomcat7以后自动支持

    2.tomcat 下面的web.xml  在最前面添加下面的filter

    <filter>
    <filter-name>CORS</filter-name>
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>CORS</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    or

    <!-- 实现跨域 -->
    <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>



  • 相关阅读:
    Linux常用命令集合
    运用栈实现表达式求值(+,-,*,/运算)
    队列
    变参函数
    C语言--递归程序的设计
    指针的灵活应用--内核链表中的container_of
    C语言-求回文数字
    压力测试和负载测试
    测试理论
    Dubbo接口调用
  • 原文地址:https://www.cnblogs.com/x-radish/p/6043586.html
Copyright © 2011-2022 走看看