您可以通过将元素嵌套在元素中来配置命名值,这些值将作为Servlet上下文初始化参数对Web应用程序可见。例如,您可以创建一个初始化参数,如下所示:
<Context> ... <Parameter name="companyName" value="My Company, Incorporated" override="false"/> ... </Context> This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml): <context-param> <param-name>companyName</param-name> <param-value>My Company, Incorporated</param-value> </context-param>
您的Java代码如下所示
ServletContext sc = getServletContext(); String companyName = sc.getInitParameter("companyName");请参阅参考http://tomcat.apache.org/tomcat-7.0-doc/config/context.html



