关于application

eqfrweg 2011-05-14 01:15:36
写了两个监听器,一个用来监听application的创建和销毁,一个用来监听属性的改变。每当启动服务器的时候,显示application被创建是正常的,怎么还会显示application属性增加呢(而且是在application创建之前)也就是说调用了以下方法(输出是我写的为了测试):
public void attributeAdded(ServletContextAttributeEvent arg0){

System.out.println("application属性增加");

}

以下为tomcat启动的记录:

2011-5-14 13:02:26 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\JDK\bin;C:\JAVAWORK\apache-tomcat-6.0.18\apache-tomcat-6.0.18\bin
2011-5-14 13:02:27 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-5-14 13:02:27 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 921 ms
2011-5-14 13:02:27 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-5-14 13:02:27 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.18
2011-5-14 13:02:29 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2011-5-14 13:02:29 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
application属性增加
application被创建
IPFilter init
authfilter init
2011-5-14 13:02:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2011-5-14 13:02:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2011-5-14 13:02:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2011-5-14 13:02:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2011-5-14 13:02:36 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-5-14 13:02:36 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-5-14 13:02:36 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/63 config=null
2011-5-14 13:02:36 org.apache.catalina.startup.Catalina start
信息: Server startup in 9361 ms
...全文
55 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wl_ldy 2011-05-14
  • 打赏
  • 举报
回复
我也刚刚按照楼主说的操作了一下:
public class ServletContextAttributeListenerTest implements
ServletContextAttributeListener {

public void attributeAdded(ServletContextAttributeEvent arg0) {
// TODO Auto-generated method stub

System.out.println("attributeAdded is called......CCCCCCCCCCCCCCCCCCCCCCCCCCCCcc");
}

public void attributeRemoved(ServletContextAttributeEvent arg0) {
// TODO Auto-generated method stub

System.out.println("attributeRemoved is called......DDDDDDDDDDDDDDDDDDDDDDDDDDDDDdd");
}

public void attributeReplaced(ServletContextAttributeEvent arg0) {
// TODO Auto-generated method stub

System.out.println("attributeReplaced is called......EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEeeee");
}

=================================================================================

public class ServletContextListenerTest implements
javax.servlet.ServletContextListener {

public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub

System.out.println("contextDestroyed is called............AAAAAAAAAAAAAAAAAAAAAAAAAAAAAa");
}

public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub

System.out.println("contextInitialized is called............BBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
}

}

====================================================================================
Eclipse的启动信息如下:

2011-5-14 13:36:53 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\MyEclipse 5.5.1 GA\bin;D:\Program Files\Apache Software Foundation\Tomcat 5.5\bin
2011-5-14 13:36:54 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-5-14 13:36:54 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2140 ms
2011-5-14 13:36:54 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-5-14 13:36:54 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.20
2011-5-14 13:36:54 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
attributeAdded is called......CCCCCCCCCCCCCCCCCCCCCCCCCCCCcc
contextInitialized is called............BBBBBBBBBBBBBBBBBBBBBBBBBBBBB

2011-5-14 13:38:11 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2011-5-14 13:38:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2011-5-14 13:38:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2011-5-14 13:38:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2011-5-14 13:38:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Overriding property struts.i18n.reload - old value: false new value: true
2011-5-14 13:38:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Overriding property struts.configuration.xml.reload - old value: false new value: true
2011-5-14 13:38:14 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-5-14 13:38:14 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-5-14 13:38:14 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/125 config=null
2011-5-14 13:38:14 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2011-5-14 13:38:14 org.apache.catalina.startup.Catalina start
信息: Server startup in 80435 ms

确实如lZ所说,但是具体原因我也不清楚,期待高手解答!

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧