Jquery RESTEasy POST在不同域中使用ajax cors错误

Jquery RESTEasy POST在不同域中使用ajax cors错误,jquery,ajax,rest,cors,resteasy,Jquery,Ajax,Rest,Cors,Resteasy,我使用REStEasy创建了POST服务,它正在chrome插件中工作。 但是使用ajax我无法调用该服务。 获取错误 XMLHttpRequest cannot load http://localhost:8080/RESTEasyJSONExample/rest/jsonServices/send. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://loca

我使用REStEasy创建了POST服务,它正在chrome插件中工作。 但是使用ajax我无法调用该服务。 获取错误

XMLHttpRequest cannot load http://localhost:8080/RESTEasyJSONExample/rest/jsonServices/send. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. 
这是因为客户端和服务器URL不同,
但我希望服务器应该允许来自任何url的请求。所以我需要在RESTAPI中实现CORS。我如何才能做到这一点。

您可以使用RESTEasy提供的类来处理CORS。该类是且必须用作请求筛选器。您需要创建自己的类来扩展RESTEasy类,并使用
@Provider
注释您的类