首页 > 代码库 > servlet_获取初始化参数

servlet_获取初始化参数

在web.xml的<servlet>标签中增添

<init-param>

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

  <param-value>XXX</param-value>

</init-param>

 

public void init() throws ServletException {
  // Put your code here
  this.setUsername(this.getInitParameter("username"));
  this.setPassword(this.getInitParameter("password"));
}

 

servlet_获取初始化参数