码迷,mamicode.com
首页 > 移动开发 > 详细

Spring测试工具返回Application

时间:2015-10-30 15:24:33      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

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;
    }

    
}

 

Spring测试工具返回Application

标签:

原文地址:http://www.cnblogs.com/duwenlei/p/4923347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!