jaxrs queryparam未加载拦截器

时间:2014-09-24 20:34:51

标签: jax-rs guice

我有以下形式的REST服务:

@GET
@NeedsInterception
public void getSomething(@QueryParam("xxx") @MyAnnotation String thing) {
    //Stuff
}

然后我有@NeedsInterception的拦截器。

在其中,我对使用@MyAnnotation注释的元素执行了一些逻辑。

但是,当调用拦截器时,MethodInvocation对象尚未使用QueryParam的值解析,而是始终"";

QueryParam解决后,我有办法让拦截发生吗?

1 个答案:

答案 0 :(得分:0)

不知道您正在使用哪种拦截器,但jax-rs ReaderInterceptor旨在包含对MessageBodyReader.readFrom的调用。由于您没有向请求正文发送@GET请求,因此无法使用此类拦截器。

ContainerRequestFilter应该有所帮助:

@Provider
public class SomeFilter implements ContainerRequestFilter {

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        MultivaluedMap<String,String> queryParameters = requestContext.getUriInfo().getQueryParameters();
    }

}
相关问题