Chinaunix首页 | 论坛 | 博客
  • 博客访问: 807886
  • 博文数量: 780
  • 博客积分: 7000
  • 博客等级: 少将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-12 09:11
文章分类

全部博文(780)

文章存档

2011年(1)

2008年(779)

我的朋友
最近访客

分类:

2008-09-12 09:13:30

public class ConfigLoadListener implements ServletContextListener {

    
public void contextInitialized(ServletContextEvent contextEvent) {  
        
try {
            WebApplicationContext context =WebApplicationContextUtils.getRequiredWebApplicationContext(contextEvent.getServletContext());
            AppContext.setApplicationContext(context);

            
//读配置
            try {
                ServletContext context2
=contextEvent.getServletContext();
                String path
=context2.getInitParameter("setting.properties");
                InputStream in 
=context2.getResourceAsStream(path);
                Properties properties 
= new Properties();
                properties.load(in);
                GlobalConstant.setCmdbProperties(properties);
                in.close();
            }
 catch (IOException e) {
                e.printStackTrace();
            }

        }
 catch (HibernateException e) {
            System.out.println(
"系统无法初始化,异常退出");
            System.out.println(e);
        }

    }

   
    
public void contextDestroyed(ServletContextEvent contextEvent) {
    }

}

--------------------next---------------------

阅读(322) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~