下面的ContextListener是我自定义的类,下面是它的代码,定义的方法没有被调用.i;我不确定内部发生了什么。请帮助我这个
package com.apalya.promo.properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletContextEvent;
import org.apache.log4j.Logger;
public class ContextListener {
Logger logger = Logger.getLogger(ContextListener.class);
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info(" !!!!!!!!PromoTv module is Going To Be Deployed
!!!!!!!! ");
System.out.println(" !!!!!!!!PromoTv module is Going To Be
Deployed !!!!!!!! ");
try {
Context ctx = new InitialContext();
ServerProperties.setConfigMap();
ServerProperties.setDbQueriesMap();
} catch (Exception e) {
logger.info(" @@@@@@@@@@@ Error In ServletContextListener
Class @@@@@@@@@ :: " + e);
}
}
public void contextDestroyed(ServletContextEvent servletContextEvent) {
logger.info(" ++++++++++ PromoTv module is Going to Stop
++++++++++++ ");
System.out.println(" ++++++++++ PromoTv module is Going to Stop
++++++++++++ ");
}
}
`
这是我的web.xml文件,我为我的用户定义的类配置了监听器类,看起来它没有被调用。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com
/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
com.apalya.promo.properties.ContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>