将拦截器应用于连接为Spring @Component的Jersey RESTful服务 [英] Applying interceptor to Jersey RESTful service wired as Spring @Component

查看:163
本文介绍了将拦截器应用于连接为Spring @Component的Jersey RESTful服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以应用Spring handler拦截器或类似于Jersey Restful服务的东西? Jersey服务是使用Spring构建的,是否在Spring @Component中?

Is it possible to apply a Spring handler interceptor or something similar to a Jersey Restful service? The Jersey service is built with Spring and is inside a Spring @Component?

我注意到Spring允许对控制器使用处理程序拦截器,但找不到任何可与我的Jersey-Rest组件一起使用的东西

I noticed that Spring allows the use of handler interceptors for controllers but cant find anything to work with my Jersey-Rest component

谢谢

推荐答案

Jersey带有自己的servlet,因此,它远远超出了Interceptor所属的Spring MVC.您可以:

Jersey comes with its own servlet and therefore is pretty much outside of Spring MVC, which the Interceptors are part of. You can either:

  • 使用Spring HTTP过滤器在Jersey周围按摩HTTPServletRequest和HTTPServletResponse
  • 在Jersey内的Spring组件周围使用Spring Handled方面来按摩方法调用和结果.

这里的家伙在总结细节方面做得很出色:

This guy here did a great job summing up the nuts and bolts: http://www.mkyong.com/webservices/jax-rs/jersey-spring-integration-example/

这篇关于将拦截器应用于连接为Spring @Component的Jersey RESTful服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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