简体   繁体   English

泽西岛资源过滤器和OPTIONS方法

[英]Jersey resource filters and OPTIONS method

I use Jersey for RESTful api in my application. 我在应用程序中将Jersey用于RESTful API。 I have some Resource, annotated with @ResourceFilters(value=...). 我有一些资源,用@ResourceFilters(value = ...)注释。 Everything works fine with methods, declared in resource, but when I try to make OPTIONS request, filters do not work. 使用资源中声明的方法,一切都可以正常工作,但是当我尝试发出OPTIONS请求时,过滤器将不起作用。 Is there any way to make filters work for my case, or I need to declare explicit OPTIONS method? 有什么方法可以使过滤器适合我的情况,还是需要声明显式的OPTIONS方法?

ResourceFilter is really meant for filtering execution of resource methods. ResourceFilter实际上是用于过滤资源方法的执行。 If you don't define OPTIONS method explicitly, the HTTP call does not get mapped to a resource method (is handled implicitly). 如果未显式定义OPTIONS方法,则HTTP调用不会映射到资源方法(隐式处理)。 You can use ContainerRequestFilter for that case. 您可以在这种情况下使用ContainerRequestFilter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM