Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个在我的 web 应用程序中使用的 3rd 方库。在axis2启动期间,我需要从这个库中调用一个init方法。
我等不及第一个请求进来了——它必须在启动时完成。
在您的 web.xml 中:
<listener> <listener-class>com.my.YourServletContextListener</listener-class> </listener>
必须在哪里YourServletContextListener实现javax.servlet.ServletContextListener并在方法中提供您的初始化代码contextInitialized(..)。
YourServletContextListener
javax.servlet.ServletContextListener
contextInitialized(..)
一旦加载了 servlet 上下文,就会调用此方法。