首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

String3跟Struts2的ServletContextAware接口

2012-10-07 
String3和Struts2的ServletContextAware接口在Spring+Struts的项目中,Spring和struts可以和Servlet进行耦

String3和Struts2的ServletContextAware接口
在Spring+Struts的项目中,Spring和struts可以和Servlet进行耦合。

但在非Action的类中,如果实现了Struts2的ServletContextAware接口,则调用

String filepath = servletContext.getRealPath("/");


时会出现取不到值的情况,报空指针错误。如果实现的是Spring3提供的ServletContextAware接口,则一切正常。


附:从Spring的Bean中获取servletcontext 和 applicationContext
    http://hjy2099.iteye.com/blog/290591

热点排行