(web.xml) understanding and application of org.springframework.web.util.WebAppRootListener

In the process of slowly learning the content in web.xml, I found such a configuration:

<context-param>
  <param-name>webAppRootKey</param-name>
  <param-value>webapp.root</param-value>
</context-param>

<listener>
	<listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
</listener>

If webAppRootKey is configured, you can use System.getProperty("webapp.root") to dynamically get the running path of the project. The general return result is for example: /usr/local/tomcat/webapps/project name. Of course, the string "webapp.root" can be written in any string. If not configured the default value is "webapp.root". For example, in the log4j.properties configuration file, you can use ${webapp.root} in the following way:
 log4j.appender.file.File=${webapp.root}/logs/xxx.log You can find it dynamically at runtime out the path of the project.

 

refer to:

http://elf8848.iteye.com/blog/2008595

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326827479&siteId=291194637