ServletConfig的描述

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String value=this.getServletConfig().getInitParameter("data");
  System.out.println(value);
  
  //获取多个配置文件
  Enumeration<String> e=this.getServletConfig().getInitParameterNames();
  while(e.hasMoreElements())
  {
   String name=(String)e.nextElement();
   String values=this.getServletConfig().getInitParameter(name);
   System.out.println("............"+values);
  }
 }

 

  <servlet>
   <servlet-name>servlet2</servlet-name>
   <servlet-class>com.itcast.info.ServletDemo</servlet-class>
   <init-param>
   <param-name>data</param-name>
  <param-value>小明</param-value>
   </init-param>
   </servlet>
<servlet-mapping>

你可能感兴趣的:(servlet)