• 解决跨域问题


    web.xml文件中,写在第一个filter上面
    <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>Accept,Origin,X-Requested-With,Content-Type,Last-Modified</param-value>
        </init-param>
        <init-param>
          <param-name>cors.exposedHeaders</param-name>
          <param-value></param-value>
        </init-param>
        <init-param>
          <param-name>cors.suppertsCredentials</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>
    
    
    
    
    pom文件
     <dependency>
                <groupId>com.thetransactioncompany</groupId>
                <artifactId>cors-filter</artifactId>
                <version>2.6</version>
            </dependency>
    
            <dependency>
                <groupId>com.thetransactioncompany</groupId>
                <artifactId>java-property-utils</artifactId>
                <version>1.9</version>
            </dependency>
        </dependencies>

      具体jar 请看文件  cors-filter-1.7.jar.zip

    本人开发小白,所写随笔有转发、有心得、随笔、所见问题、或者感觉不错的东西,希望能帮助他人,同时也相当给自己方便!(未来及标明出处,望原作者以及读者见谅海涵!一切为了能解决问题。。。。)
  • 相关阅读:
    http://caibaojian.com/jquery/ JQuery在线查询手册
    验证码
    显式提交/隐式提交 //ajax方式的隐式提交
    事物 银行转账业务
    模板 Template
    登录页面跳转与错误提示信息
    连接池 八种基本类型
    文件,文件夹的基本操作--------数据流的传输
    vim编辑器
    Linux中创建和使用静态库&动态库
  • 原文地址:https://www.cnblogs.com/chengjiao/p/8337218.html
Copyright © 2020-2023  润新知