当前位置: 代码迷 >> Java Web开发 >> 监听器里的东西为什么会在tomcat启动时加进去?
  详细解决方案

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

热度:145   发布时间:2011-10-05 23:33:54.0
监听器里的东西为什么会在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" content="0">   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
    <%
        application.setAttribute("name","tom");
        application.setAttribute("name","123");
        application.removeAttribute("name");
     %>
  </body>
</html>



[ 本帖最后由 小小鸟001 于 2011-10-5 23:51 编辑 ]
搜索更多相关主题的帖子: 信息  控制台  

----------------解决方案--------------------------------------------------------
没看懂
----------------解决方案--------------------------------------------------------
  相关解决方案