在带有监听器的servlet中,执行的顺序是这样的,首先建立servletListerner,然后运行,初始化ServletContext,然后监听ServletContext的变化,最后ServletContext被销毁,加ServletListener的时候不用添加其他的什么配置只在web.xml里面加上监听器就可以了,
servlet可以设置优先级的
可以把serlet的启动优先级设高一点
<load-on-startup> 1 </load-on-startup>
<servlet>
<servlet-name> proxoolServletConfigurator </servlet-name>
<servlet-class> org.logicalcobwebs.proxool.configuration.ServletConfigurator </servlet-class>
<init-param>
<param-name> xmlFile </param-name>
<param-value> WEB-INF/proxool.xml </param-value>
</init-param>
<load-on-startup> 1 </load-on-startup>
</servlet>
<servlet>
<servlet-name> proxoolAdmin </servlet-name>
<servlet-class> org.logicalcobwebs.proxool.admin.servlet.AdminServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> proxoolAdmin </servlet-name>
<url-pattern> /proxooladmin </url-pattern>
</servlet-mapping>
<listener>
<listener-class> com.mission.init.SysContextListener </listener-class>
</listener>
来源:oschina
链接:https://my.oschina.net/u/4094976/blog/3063275