我有以下课程运行
@Provider
@ServerInterceptor
@RedirectPrecedence
public class SubsidiaryOpenInterceptor implements PostProcessInterceptor, AcceptedByMethod {
@Override
public boolean accept(Class clazz, Method method) {
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
for (Annotation[] paramAnnotation : paramAnnotations) {
for (Annotation a : paramAnnotation) {
if (a instanceof PathParam && ((PathParam) a).value().equals("idSubsidiary"))
return true;
}
}
return false;
}
@Override
public void postProcess(ServerResponse response) {
final Annotation[][] paramAnnotations = response.getResourceMethod().getParameterAnnotations();
for (Annotation[] paramAnnotation : paramAnnotations) {
for (Annotation a : paramAnnotation) {
if (a instanceof PathParam && ((PathParam) a).value().equals("idSubsidiary")) {
// get the value of "idSubsidiary", it should be an Integer, and do something.
}
}
}
}
}
现在我想@PathParam("idSubsidiary") Integer idSubsidiary
从发出请求的 url 中检索 idSubsidiary 设置的值。
在这个阶段有可能知道吗?
是否有一种策略可以让我在流程的这一点获得这些数据?
我尝试使用 MessageBodyWriterInterceptor,但无法成功。也尝试过使用@Context HttpServletRequest req
但没有成功。