首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

WEB项目启动加载的实现形式整理

2013-12-21 
WEB项目启动加载的实现方式整理方法一:实现org.springframework.beans.factory.config.BeanPostProcessor

WEB项目启动加载的实现方式整理
方法一:
实现org.springframework.beans.factory.config.BeanPostProcessor接口:

public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor {              public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {              return bean;        }                public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {              return bean;          }      }  

在spring配置文件中添加:
<bean name="code">public class SysInitBean implements InitializingBean, ServletContextAware {      public void afterPropertiesSet() throws Exception {      }        @Override      public void setServletContext(ServletContext servletContext) {      }  }  

在spring配置文件中添加:
<bean name="code">public class RedisInitListener implements ServletContextListener {        @Override      public void contextDestroyed(ServletContextEvent sce) {        }        @Override      public void contextInitialized(ServletContextEvent sce) {          //WebApplicationContext wa = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());          ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");             }  }  

在web.xml中添加listener:
<listener>        <listener-class>***.***.RedisInitListener</listener-class>    </listener>

热点排行