@GET方法上的拦截器在JAX-RS端点中不起作用
我写了这个拦截器@GET方法上的拦截器在JAX-RS端点中不起作用,jax-rs,interceptor,Jax Rs,Interceptor,我写了这个拦截器 @Slf4j public class APIExceptionInterceptor { @AroundInvoke public Object mdbInterceptor(InvocationContext ctx) throws Exception { System.out.println("*** Intercepting call to EmailMDB.mdbInterceptor()");
@Slf4j
public class APIExceptionInterceptor {
@AroundInvoke
public Object mdbInterceptor(InvocationContext ctx) throws Exception
{
System.out.println("*** Intercepting call to EmailMDB.mdbInterceptor()");
return ctx.proceed();
}
}
现在我在我的课堂上注释它。但出于某种原因,它根本没有被调用。
我真的不明白为什么
@Path("/somePath")
//Here I put Interceptor Annotation
@Interceptors( {APIExceptionInterceptor.class})
@Slf4j
public class ExceptionalResource {
@Context
private UriInfo uriInfo;
@GET
@Produces(MediaType.APPLICATION_JSON)
public MyDTO getPang() {
}
正如你所看到的,我把它放在了课堂上。但如果我将断点放在ApiInterceptorException类中,它就永远不会被调用。Jersey JAX-RS拦截器真的不起作用吗。相反,您必须使用ExceptionMapper???