| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1415 人关注过本帖
标题:监听器里的东西为什么会在tomcat启动时加进去?
只看楼主 加入收藏
小小鸟001
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-7-13
结帖率:100%
收藏
已结贴  问题点数:0 回复次数:1 
监听器里的东西为什么会在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. 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 编辑 ]
搜索更多相关主题的帖子: 信息 控制台 
2011-10-05 23:33
菜鸟的悲哀
Rank: 2
等 级:论坛游民
帖 子:2
专家分:14
注 册:2011-10-5
收藏
得分:14 
没看懂
2011-10-05 23:46
快速回复:监听器里的东西为什么会在tomcat启动时加进去?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037872 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved