类 WebAppRootListener
- java.lang.Object
- org.springframework.web.util.WebAppRootListener
- 所有已实现的接口:
EventListener
,ServletContextListener
public class WebAppRootListener extends Object implements ServletContextListener
Listener that sets a system property to the web application root directory. The key of the system property can be defined with the "webAppRootKey" init parameter at the servlet context level (i.e. context-param in web.xml), the default key is "webapp.root".Can be used for toolkits that support substitution with system properties (i.e. System.getProperty values), like log4j's "${key}" syntax within log file locations.
Note: This listener should be placed before ContextLoaderListener in
web.xml
, at least when used for log4j. Log4jConfigListener sets the system property implicitly, so there's no need for this listener in addition to it.WARNING: Some containers, e.g. Tomcat, do NOT keep system properties separate per web app. You have to use unique "webAppRootKey" context-params per web app then, to avoid clashes. Other containers like Resin do isolate each web app's system properties: Here you can use the default key (i.e. no "webAppRootKey" context-param at all) without worrying.
WARNING: The WAR file containing the web application needs to be expanded to allow for setting the web app root system property. This is by default not the case when a WAR file gets deployed to WebLogic, for example. Do not use this listener in such an environment!
- 从以下版本开始:
- 18.04.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
WebUtils.setWebAppRootSystemProperty(javax.servlet.ServletContext)
,System.getProperty(java.lang.String)
构造器概要
构造器 构造器 说明 WebAppRootListener()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
contextDestroyed(ServletContextEvent event)
Receives notification that the ServletContext is about to be shut down.void
contextInitialized(ServletContextEvent event)
Receives notification that the web application initialization process is starting.
构造器详细资料
WebAppRootListener
public WebAppRootListener()
方法详细资料
contextInitialized
public void contextInitialized(ServletContextEvent event)
从接口复制的说明:javax.servlet.ServletContextListener
Receives notification that the web application initialization process is starting.All ServletContextListeners are notified of context initialization before any filters or servlets in the web application are initialized.
- 指定者:
contextInitialized
在接口中ServletContextListener
- 参数:
event
- the ServletContextEvent containing the ServletContext that is being initialized
contextDestroyed
public void contextDestroyed(ServletContextEvent event)
从接口复制的说明:javax.servlet.ServletContextListener
Receives notification that the ServletContext is about to be shut down.All servlets and filters will have been destroyed before any ServletContextListeners are notified of context destruction.
- 指定者:
contextDestroyed
在接口中ServletContextListener
- 参数:
event
- the ServletContextEvent containing the ServletContext that is being destroyed