用servlet里的监听器呀,实现ServletContextListener接口,写一个监听器类,然后配置到web.xml文件中。当服务器一启动,就会先调用这个类的方法!!可以在里面实现数据库数据的初始化!

解决方案 »

  1.   

    用监听做
    <listener>
        <listener-class>com.类名</listener-class>
      </listener>
      

  2.   

    我想要使用spring来管理bean,hibernate做事物处理。现在hibernate的配置在spring配置文件里。如何调用?
      

  3.   

    jdbc连接,光用hibernate我也会,但是加了spring后怎么用就不知道了,还请各位高人帮帮忙,支持下
      

  4.   

    我现在开发一个功能,是在weblogic启动时调用某方法(系统是hibernate+spring)。
    我看系统中已有的类似功能的处理是在context-index.xml文件中,定义service时增加了init-method的配置,如下:
    <bean id="xxxService" class="xxx.xxx.XxxService" autowire="byName" factory-method="getInstance" init-method="initXxxBean"/>
    其中factory-method和init-method具体的原理如何,我不清楚。
      

  5.   

    上网查了一下,xml文件中的factory-method是指定bean的实例化方法,而init-method是指定在bean实例化后要调用的方法(bean里定义好的方法)。
    现在的感觉是spring框架启动时,就将bean实例化,因此就能调用init-method指定的方法,从而感觉是weblogic启动时就执行了指定的方法。
    现在的疑问是,是否spring框架启动时,就将xml中定义的bean都实例化了?不是说是在使用bean时才实例化么?