跨域解决方案

阅读更多
场景一:
让tomcat下一个java web工程接受跨域请求:在web.xml中添加过滤器

   CorsFilter
   org.apache.catalina.filters.CorsFilter


   CorsFilter
   /*


场景二:
让tomcat下所有工程接受跨域请求:修改tomcat配置


场景三:
让nginx下所有静态文件接受跨域请求
    server {
       listen       8081;
       listen       localhost:8081;
       server_name  somename  alias  another.alias;

       location / {
         
                                add_header Access-Control-Allow-Origin "*";
                                add_header Access-Control-Allow-Headers X-Requested-With;
                                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
                         

           root   html;
           index  index.html index.htm;
       }
    }

你可能感兴趣的:(跨域请求问题)