java - 在 Tomcat 7 中加载我的 ServletContextListener

标签 java tomcat7

Tomcat 新手,在 Eclipse 环境中运行 Tomcat 7。

我关注了a tutorial用于创建 ServletContextListener 类。我的问题很简单,我如何在 Tomcat 中加载和运行它?我可以使用注释吗?我需要编辑 xml 文件吗?

最佳答案

Javadoc救援:

In order to receive these notification events, the implementation class must be either declared in the deployment descriptor of the web application, annotated with WebListener, or registered via one of the addListener methods defined on ServletContext.

关于java - 在 Tomcat 7 中加载我的 ServletContextListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10538867/

相关文章:

java - 如何解决以下 stub 是不必要的 - Mockito - Android

mysql - 如何修复 : "No suitable driver found for jdbc:mysql://localhost/dbname" error when using pools?

eclipse - 在 Eclipse 中启动服务器后找不到 Liferay 主页

java - GWT,Tomcat,2个模块,JRebel:DevMode在错误的位置查找nocache.js并显示未找到404

java - 使用 tomcat 部署期间避免临时 404 错误

java - 将 Avro 二进制字符串转换为 Json

java - GridLayout 不适用于 BoxInsetLayout

java - 在运行时修改Tomcat中的属性文件

java - 相机 2 基本 : Application:transformClassesWithDexForDebug

java - 在 Eclipse 中并行运行 JUnit 参数化测试