JSON REST Get-Request正在等待Tomcat上的CORS在Chrome/Firefox上的使用 [英] JSON REST Get-Request is pending with CORS on Tomcat for Chrome/Firefox

查看:55
本文介绍了JSON REST Get-Request正在等待Tomcat上的CORS在Chrome/Firefox上的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 http://software.dzhuvinov.com/cors-filter.html 当前版本1.9.

We have built a REST Backend with Jersey 1.9.1 on Tomcat 7.0.42 using the CORS Filter from http://software.dzhuvinov.com/cors-filter.html current version 1.9.

从Chrome版本31或Firefox版本26执行以下JS代码时:

When executing the following JS code from Chrome Version 31 or Firefox Version 26:

$.ajax({
  type: 'GET', contentType: 'application/json',
  url: 'http://tomcat.bailamos-salsa.ch/bailamossalsa/app-api/course',
  success: function(response) {
    alert(response);
  }
});

预检OPTIONS请求以代码200返回,但是对于某些设备,以下GET请求挂起并且永不返回.我们在Windows和OSX上测试了某些设备是否可以正常工作,但在其他设备上却无法在相同的浏览器版本上工作.

the preflight OPTIONS request returns with Code 200, but fro some devices the following GET request hangs and never returns. We tested on Windows and OSX, for some devices it worked, but for other devices it did not work with the identical browser versions.

我们在服务器上调试了CORS筛选器,但无法识别任何错误.

We debugged the CORS Filter on the server but could not identify any errors.

可以在这里找到一个测试用例: http://jsfiddle.net/d27Zb/

A test case can be found here: http://jsfiddle.net/d27Zb/

非常感谢您的帮助,我们很拼命.

Any help is very appreciated, we are desperate.

推荐答案

对于将来遇到此问题的人,调试此问题的最简单方法是分析系统之间的差异.如果您在多个环境中使用相同的浏览器,并且只能在其中一些环境中使用,则可能是防火墙问题.如评论中所述,在Mac上关闭防火墙的CORS过滤器可以解决此问题.

For people who come across this in the future, the easiest way to debug this is to analyze the differences between systems. If you're using the same browser in multiple environments and it only works in some of them, it's probably a firewall issue. As mentioned in the comments, turning off the CORS filter for their firewall on their Mac fixed the issue.

这篇关于JSON REST Get-Request正在等待Tomcat上的CORS在Chrome/Firefox上的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆