在 Apache CXF - JAX-RS 中使用 FIQL 查询时如何注入 @Context?
我正在尝试实现 FIQL 搜索查询,并且遵循 http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-FIQLsearchqueries。
问题是 SearchContext 始终为 null,并且我在运行时收到 NullPointerException。
我的示例代码是:
@Context
private SearchContext searchContext;
@GET
@Path("/actor/")
@Override
public List<Actor> getActorBy() {
SearchCondition<District> sc = searchContext.getCondition(Actor.class);
}
在 searchContext 上执行 getCondition 方法时,出现 NullPointerException。
其他休息电话正在工作。
有没有办法注入或配置 SearchContext 以便我能够执行 fiql 搜索查询?
I am trying to implement a FIQL search queries and I am following the guide at http://cxf.apache.org/docs/jax-rs-advanced-features.html#JAX-RSAdvancedFeatures-FIQLsearchqueries.
The issue is that the SearchContext is always null and I am getting a NullPointerException at runtime.
My sample code is :
@Context
private SearchContext searchContext;
@GET
@Path("/actor/")
@Override
public List<Actor> getActorBy() {
SearchCondition<District> sc = searchContext.getCondition(Actor.class);
}
I am getting the NullPointerException when executing the method getCondition on searchContext.
The others rest calls are working.
Is there a way to inject or configure the SearchContext so I can be able to execute a fiql search query ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注入 @Context 似乎存在一些问题...我能够通过以下方式使其工作
There seems to be some problem injecting @Context(s)... I was able to get this working by
您需要将 SearchContextProvider 添加到 jaxrs:server
示例中:
You need to add a SearchContextProvider to your jaxrs:server
example: