1.什么是Enumeration
Enumeration接口本身不是一个数据结构。但是,对其他数据结构非常重要。 Enumeration接口定义了从一个数据结构得到连续数据的手段。例如,Enumeration定义了一个名为nextElement的方法,可以用来从含有多个元素的数据结构中得到的下一个元素。
Enumeration接口提供了一套标准的方法,由于Enumeration是一个接口,它的角色局限于为数据结构提供方法协议。下面是一个使用的例子:
//e is an object that implements the Enumeration interface
while (e.hasMoreElements()) {
Object o= e.nextElement();
System.out.println(o);
}
本文来自 zhiweianran 的优快云博客 ,全文地址:https://blog.youkuaiyun.com/zhiweianran/article/details/7672433?utm_source=copy
2.批量接受request请求的方法
原理很简单,request.getParameterNames获取所有的请求参数名,然后利用Enumeration特性获取对应的值,加上逻辑判断,最后转化为JSON对象返回!
public static JSONObject convertRequestParametersToJSONObject(final HttpServletRequest request,