|
web程序的初始化问题——ServletContextListener
时间: 2005-01-04
应用ServletContextListener接口,可以实现在web应用程序初始化时,自动运行一些初始化程序。 ServletContextListener接口定义的方法
应用此接口时,要在web.xml文件内定义“监听器类”的名称,此时要注意: 在Servlet规范中并未限制一个Web应用程序只能对应一个“监听器类”,但是在web.xml内定义<listener>元素时得注意下列两点: 举例: web.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" <description> Test.java: package com.chuyang; import javax.servlet.ServletContextEvent; public class Test implements ServletContextListener { |
web程序的初始化问题——ServletContextListener
最新推荐文章于 2024-03-03 12:14:37 发布
本文介绍了如何使用ServletContextListener接口实现Web应用程序的初始化与销毁操作。通过示例代码详细展示了如何定义监听器类,并在web.xml中配置该类。
web程序的初始化问题——ServletContextListener
2006-08-01 12:13
836

被折叠的 条评论
为什么被折叠?



