1
如何在我的apache cxf Web服務應用程序中訪問Servlet上下文?我如何才能訪問apache cxf中的Servet上下文?
我使用apache cxf 2.2.7和Json作爲數據傳輸格式。
如何在我的apache cxf Web服務應用程序中訪問Servlet上下文?我如何才能訪問apache cxf中的Servet上下文?
我使用apache cxf 2.2.7和Json作爲數據傳輸格式。
看看ServletContextAware
界面:在Web上下文中註冊的Spring bean可以訪問ServletContext
。更積極的方法是從Web上下文請求名爲servletContext
的bean或使用ServletContextParameterFactoryBean
。否則(如果你不使用Spring + CXF,這是不常見的),你需要實現javax.servlet.ServletContextListener
並在<web-app> → <listener> → <listener-class>
中註冊這個實現。該實現應該保存ServletContext
稍後將由您的WebService使用。
非常感謝,但我仍不清楚如何實現這一點。你能否分享一些示例代碼來解釋如何實現結果? – Surya 2012-01-06 13:10:28
不幸的是,我沒有任何代碼。你在你的應用程序中使用[Spring](http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/)嗎? – 2012-01-06 14:29:42
是的。我用apache-cxf使用spring。 – Surya 2012-03-15 12:40:09