当Servlet程序中ServletConfig接口与ServletContext里面初始化参数比较多的时候,我们采用枚举的方式来更快的操作
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ServletConfig config = this.getServletConfig(); Enumeration<String> names = config.getInitParameterNames(); while(names.hasMoreElements()){ String nextElement = names.nextElement(); String parameter = config.getInitParameter(nextElement); System.out.println(nextElement+":"+parameter); } }