大家好,我现在已经知道了ContextLoaderPlugin和ContextLoaderListener都是用来启动spring的。ContextLoaderPlugin和struts相关。但是我不清楚它们之间具体的区别,什么时候应该用ContextLoaderListener,什么时候应用ContextLoaderPlugin,以及在struts中可不可以用ContextLoaderListener,在项目中有没有这两种方式都用的。另外还有一个ContextLoaderServlet和ContextLoaderListener有什么区别,什么时候应该用ContextLoaderServlet
先谢过了!!!!!!!

解决方案 »

  1.   

    ContextLoaderListener比ContextLoaderServlet 加载的时机要早,ContextLoaderListener要求servlet2.3以上
      

  2.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【lttzdllf】截止到2008-07-03 00:22:43的历史汇总数据(不包括此帖):
    发帖的总数量:24                       发帖的总分数:910                      
    结贴的总数量:23                       结贴的总分数:880                      
    无满意结贴数:2                        无满意结贴分:50                       
    未结的帖子数:1                        未结的总分数:30                       
    结贴的百分比:95.83 %               结分的百分比:96.70 %                  
    无满意结贴率:8.70  %               无满意结分率:5.68  %                  
    值得尊敬
      

  3.   

    ContextLoaderPlugin是spring为struts的ActionServlet提供的spring应用程序配置环境,以此方式将struts的Action托管给spring 。而ContextLoaderListener是一个监听器。区别在于,两种方式加载的WebApplicationContext,以不同的Key存放在ServletContext中。而如果你定义了HibernateFilter的话,spring会利用WebApplicationContextUtils来获取WebApplicationContext,而此类并不识别ContextLoaderPlugIn类所加载的上下文,此时便会抛出异常: No WebApplicationContext found: no ContextLoaderListener registered?利用ContextLoaderListenter来加载dao、service级别的context,而对于struts的action,用ContextLoaderPlugIn加载。