大佬教程收集整理的这篇文章主要介绍了jquery – Cross Origin访问restful jax-rs服务,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@Path("/foo/{datE}") @Produces(Array("application/xml")) @CrossOriginresourceSharing(allowAllOrigins = truE) class Foo { @GET @Path("{iD}") def dostuff(@PathParam("date") date: util.Date,@PathParam("id") id: int) = ... }
在我的Spring applicationContext.xml中,我在jaxrs:providers列表中注册了一个cors过滤器
<bean id="corsFilter" class="org.apache.cxf.rs.security.cors.CrossOriginresourceSharingFilter" p:allowCredentials="true"/>
我可以通过http:// localhost:8080 / foo / 2012-07-17 / 123直接从Firefox / IE使用端点,但我正在尝试构建一个服务,该服务将从另一个Web应用程序调用,以便解耦二.
当我直接通过Firefox发出请求时,我看到以下内容:
Response Headers Content-Length 5699 Content-Type application/xml Date Wed,18 Jul 2012 16:49:09 GMT Server Apache-Coyote/1.1 request Headers Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip,deflate Accept-Language en-us,en;q=0.5 Cache-Control max-age=0 Connection keep-alive Cookie DWRSESSIONID=Q62Vf$dv*S9sA8EaJm6jKW6$pyj; JSESSIONID=17E120C419F075B505447F151124BC18 Host localhost:9580 User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
当我从本地磁盘上的网页通过Ajax发出请求时,我看到以下内容:
Response Headers Access-Control-Allow-Cred... true Access-Control-Allow-Orig... * Content-Length 6177 Content-Type application/xml Date Wed,18 Jul 2012 16:41:21 GMT Server Apache-Coyote/1.1 request Headers Accept */* Accept-Encoding gzip,en;q=0.5 Connection keep-alive Cookie DWRSESSIONID=Q62Vf$dv*S9sA8EaJm6jKW6$pyj; JSESSIONID=17E120C419F075B505447F151124BC18 Host localhost:8080 Origin null User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
我可以使用prototype.js在IE中正常工作,但是Firefox更复杂,我假设因为Web服务是由NTLM servlet过滤器预测的.我一直在使用jQuery用于非msie浏览器,以便使用XhrFields属性传递凭据,我可以看到我的服务在调试器中从IE和& Firefox,但是从Firefox调用时我的回复是空白的.
这甚至可能吗?
以上是大佬教程为你收集整理的jquery – Cross Origin访问restful jax-rs服务全部内容,希望文章能够帮你解决jquery – Cross Origin访问restful jax-rs服务所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。