---
title: "jee中的监听器"
author: "BBjava"
date: "2012-03-22T13:15:53Z"
tags: []
categories: ["开源软件"]
slug: "jee"
draft: false
lastmod: "2012-03-22T13:15:53Z"
id: 1461328
url: "https://bbjava.iteye.com/blog/1461328"
---

在web.xml是有一项
	
```xml
<listener>
		<listener-class>org.iteye.bbjava.YourFuncListener</listener-class>
	</listener>

```


其中<span style="color:darkred">org.iteye.bbjava.yourFuncListener</span>就是你自已的监听器。
下面是监听器的写法：

```java

public class YourFuncListener implements ServletContextListener {

	private static final long serialVersionUID = -2153378435692476097L;
		public void contextDestroyed(ServletContextEvent arg0) {
			// TODO Auto-generated method stub
			
		}
		public void contextInitialized(ServletContextEvent event) {
                         // TODO Auto-generated method stub
		}
}


```


> 
> ServletContextEvent :
> This is the event class for notifications about changes to the servlet context of a web application. 


什么时候需要监听器？