关于Servlet程序中ServletConfig接口与ServletContext里面初始化参数的遍历

 

  当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);
    }

}

 

上一篇:七、Flutter优化Tabbar


下一篇:win10系统解决vscode乱码问题