Access to Font at from origin has been by CORS plicy: No ‘Access-Control-Allow-Origin’ tomcat 解决方法

前言

    在请求tomcat上的字体文件的时候,遇到了以下错误

Access to Font at “xxx” from origin “xxx” has been by CORS plicy:
No ‘Access-Control-Allow-Origin’header is present on the requested resource. 
Origin “xxx” is therefore not allowed access.

在这里插入图片描述解决方法

    在api服务器的tomcat的web.xml中添加CorsFilter过滤器


    CorsFilter
    com.thetransactioncompany.cors.CORSFilter


      CorsFilter
      /*

    下载cors-filter-.jarjava-property-utils-.jar两个jar文件下,放在tomcat的lib中。

    下载地址:
        cors-filter-2.4.jar
        http://search.maven.org/remotecontent?filepath=com/thetransactioncompany/cors-filter/2.4/cors-filter-2.4.jar

        java-property-utils-1.9.1.jar
        http://search.maven.org/remotecontent?filepath=com/thetransactioncompany/java-property-utils/1.9.1/java-property-utils-1.9.1.jar

    重启tomcat。

你可能感兴趣的:(Tomcat)