在 OData4j 服务提供者中访问 HttpServletRequest
我意识到这几乎是 如何在 Odata 中访问 HttpServletRequest 的重复服务提供商,但由于它没有得到任何答复,我会尝试一下机会。
这个问题的共识似乎是“使用 @Context HttpServletRequest req 来注入它”,我不知道应该如何做到这一点,因为我根本不熟悉这个概念。
我正在使用 jersey servlet 容器。这是我的 web.xml
<servlet>
<description>Servlet container</description>
<display-name>Default</display-name>
<servlet-name>Default</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<description></description>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>org.odata4j.producer.resources.ODataResourceConfig</param-value>
</init-param>
<init-param>
<description></description>
<param-name>odata4j.producerfactory</param-name>
<param-value>mypackage.MySqlProducerFactory</param-value>
</init-param>
</servlet>
我应该如何处理这个问题?
多谢!
I realise that this is pretty much a duplicate of How to access HttpServletRequest in Odata service provider, but since it didn't get any anwser I'll try my chances.
The concensus for this problem seems to be "use @Context HttpServletRequest req to inject it" by I have no idea how I should do this, since I am not familiar with this concept at all.
I am using a jersey servlet container. Here's my web.xml
<servlet>
<description>Servlet container</description>
<display-name>Default</display-name>
<servlet-name>Default</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<description></description>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>org.odata4j.producer.resources.ODataResourceConfig</param-value>
</init-param>
<init-param>
<description></description>
<param-name>odata4j.producerfactory</param-name>
<param-value>mypackage.MySqlProducerFactory</param-value>
</init-param>
</servlet>
How should I approach this?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论