[英]Getting null from context
Why am I getting resourceInfo as null in this. 为什么我在此将resourceInfo设置为null。 Is there any other way to get resource class and resource method? 还有其他获取资源类和资源方法的方法吗?
@Provider
@Authenticate
@Transactional
public class TestFilter2 implements ContainerRequestFilter {
private final SessionRepository sessionRepository;
@Context
public ResourceInfo resourceInfo;
@Inject
public TestFilter2(SessionRepository sessionRepository) {
this.sessionRepository = sessionRepository;
}
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
check();
}
private void check() {
sessionRepository.getActiveSessionBySessionId("dsfsdf");
}
}
@context
annotation doesn't allow you to inject ResourceInfo
type, here are the types that you can inject using @context
: @context
批注不允许您注入ResourceInfo
类型, 这是您可以使用@context
注入的类型:
- SecurityContext 安全上下文
- Request 请求
- ResourceContext 资源上下文
- ServletConfig ServletConfig
- ServletContext ServletContext
- HttpServletRequest HttpServletRequest
- HttpServletResponse HttpServletResponse
- HttpHeaders HttpHeaders
- UriInfo UriInfo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.