Spring测试工具返回Application

package pmisf.webservice.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;


public class SpringUtil implements ServletContextListener {
    

    private static WebApplicationContext springContext;
    
    public SpringUtil() {
        super();
    }
    
    public void contextInitialized(ServletContextEvent event) {
        springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    }
    

    public void contextDestroyed(ServletContextEvent event) {
    }
    
    public static ApplicationContext getApplicationContext() {
        return springContext;
    }

    
}

 

posted @ 2015-10-30 15:12  哎呦喂,我的小祖宗╰つ  阅读(220)  评论(0编辑  收藏  举报