在web.xml中配置变量

<context-param>

  <param-name>name</param-name>

  <param-value>value<param-value>

</context-param>

在servlet中读取  String num = servletContext.getInitParameter("name");

原文地址:https://www.cnblogs.com/bsyx/p/4139662.html