为什么我在此将resourceInfo设置为null。还有其他获取资源类和资源方法的方法吗?
@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");
}
}
答案 0 :(得分:-1)
@context
批注不允许您注入ResourceInfo
类型,here是您可以使用@context
注入的类型:
- SecurityContext
- 请求
- ResourceContext
- ServletConfig
- ServletContext
- HttpServletRequest
- HttpServletResponse
- HttpHeaders
- UriInfo