在Spring+Struts的项目中,Spring和struts可以和Servlet进行耦合。
但在非Action的类中,如果实现了Struts2的ServletContextAware接口,则调用
时会出现取不到值的情况,报空指针错误。如果实现的是Spring3提供的ServletContextAware接口,则一切正常。
附:从Spring的Bean中获取servletcontext 和 applicationContext
[url]http://hjy2099.iteye.com/blog/290591[/url]
但在非Action的类中,如果实现了Struts2的ServletContextAware接口,则调用
String filepath = servletContext.getRealPath("/");
时会出现取不到值的情况,报空指针错误。如果实现的是Spring3提供的ServletContextAware接口,则一切正常。
附:从Spring的Bean中获取servletcontext 和 applicationContext
[url]http://hjy2099.iteye.com/blog/290591[/url]