日期:2014-05-17  浏览次数:20809 次

监听器里的东西为什么会在tomcat启动时加进去?
程序代码:

控制台输出如下:

信息: Deploying web application directory qi002
非法文字过滤初始化
2011-10-5 23:20:19 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory qi003
添加application范围属性,属性名com.sun.faces.config.WebConfiguration com.sun.faces.config.WebConfiguration@bd4dc2  
2011-10-5 23:20:19 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2011-10-5 23:20:19 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory test
2011-10-5 23:20:19 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory test.myeclipse.bak
2011-10-5 23:20:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory test1
2011-10-5 23:20:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory test2
2011-10-5 23:20:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory test3
2011-10-5 23:20:20 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-10-5 23:20:20 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-10-5 23:20:20 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31 config=null
2011-10-5 23:20:20 org.apache.catalina.startup.Catalina start
信息: Server startup in 3288 ms
这两行红色的部分怎么被加进来了
添加application范围属性,属性名org.apache.jasper.runtime.JspApplicationContextImpl org.apache.jasper.runtime.JspApplicationContextImpl@a33d00
添加application范围属性,属性名name tom
替换application范围属性,属性名name
移除applocation范围属性,属性名name




程序代码:

监听器代码
package net.qijiabin.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;

public class MyServletContextAttributeListener implements ServletContextAttributeListener{

  public void attributeAdded(ServletContextAttributeEvent scab) {
  System.out.println("添加application范围属性,属性名"+scab.getName()+" "+scab.getValue());
  }

  public void attributeRemoved(ServletContextAttributeEvent scab) {
  System.out.println("移除applocation范围属性,属性名"+scab.getName());
  }

  public void attributeReplaced(ServletContextAttributeEvent scab) {
  System.out.println("替换application范围属性,属性名"+scab.getName());
  }

}





程序代码:

web.xml配置如下
  <listener>
  <listener-class>
  net.qijiabin.listener.MyServletContextAttributeListener
  </listener-class>
  </listener>



程序代码:

测试代码如下
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'application.jsp' starting page</title>
   
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires"