zoukankan      html  css  js  c++  java
  • 配置tomcat允许跨域访问,cors跨域资源共享

    1.导入cors-filter-1.7.jar,java-property-utils-1.9.jar两个jar包

    2.在web.xml里配上:

    <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>
  • 相关阅读:
    JSP文件上传下载组件(2)
    JSP文件上传下载组件(1)
    FetchProfile类的作用
    html(二) -- 文本标签和实体字符
    html (一)-- 概述
    单元测试框架--junit
    内省和BeanUtils
    工厂模式
    反射
    观察者设计模式
  • 原文地址:https://www.cnblogs.com/cnsdhzzl/p/8473812.html
Copyright © 2011-2022 走看看