在web.xml中实现ServletContainerInitializer的类 [英] Class implementing ServletContainerInitializer in web.xml

查看:221
本文介绍了在web.xml中实现ServletContainerInitializer的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能指出一个在 web.xml 文件中实现 ServletContainerInitializer 接口的类,或者你是否需要在 META-INF / services / javax.servlet.ServletContainerInitializer 下添加一个文件让J2EE服务器拿起它?



如果可以通过 web.xml 文件,请解释如何。

解决方案

我已经检查了 Java Servlet规范3.0 ,但我没有发现任何线索它可以通过 web.xml 进行配置。我认为唯一的方法是
META-INF / services / javax.servlet.ServletContainerInitializer 文件。



<请注意, META-INF / services / javax.servlet.ServletContainerInitializer 是一个文件(不是目录),必须包含initalizer的完全限定名称,喜欢:

  com.example.MyServletContainerInitializer 

它也可能在战争中(用Tomcat 7.0.21测试)。



这是一个完整的例子: http://nullhaus.com/2011/03/using-servlets-3-0-servletcontainerinitializer/


Can you point to a class implementing the ServletContainerInitializer interface in the web.xml file or do you have to add a file under the META-INF/services/javax.servlet.ServletContainerInitializer to have a J2EE server pick it up?

If it's possible via the web.xml file, please explain how.

解决方案

I've checked the Java Servlet Specification 3.0 and I've not found any clue that it could be configured via web.xml. I think the only way is the META-INF/services/javax.servlet.ServletContainerInitializer file.

Please note that the META-INF/services/javax.servlet.ServletContainerInitializer is a file (not a directory) which has to contain the fully qualified name of the initalizer, like:

com.example.MyServletContainerInitializer

It could be inside the war too (tested with Tomcat 7.0.21).

Here is a complete example: http://nullhaus.com/2011/03/using-servlets-3-0-servletcontainerinitializer/

这篇关于在web.xml中实现ServletContainerInitializer的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆